Hi All,
I am adding a custom combobox template to one of the grids column like this.
Now Please do note that the itemssource resource is actually in my xaml page. It is not getting called at all by default. So I am explicitly assigning the itemssource to the combobox in the rowloaded event.
This thing is working fine when the data is getting loaded for the first time and the combobox is also coming filled with its data. But when I am selecting an item from the combobox. It is again recreating the celltemplate and thus I am loosing the data in the combobox.
Please do note that the itemssource of the datagrid and the itemssource of the combobox both implements inotifypropertychanged. And at present I am coding this in SL3. But in case required I can also try implementing this in SL4.
I hope I was clear about my problem. Any suggestions to fix this issue will be much appreciated.
Regards
Tiklu
I am adding a custom combobox template to one of the grids column like this.
string
controlid =
"CustomDrop"
;
string
SelectedValue =
"ContryName"
;
string
SelectedValuePath =
"Name"
;
string
DisplayMemberPath =
"Name"
;
var CellTemp =
new
StringBuilder();
CellTemp.Append(@
"<DataTemplate xmlns="
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
"
xmlns:x=
""
http:
//schemas.microsoft.com/winfx/2006/xaml""
xmlns:telerikComboBox=
""
clr-
namespace
:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input
""
>
<telerikComboBox:RadComboBox x:Name=
""
" + controlid + @"
""
DisplayMemberPath=
""
" + DisplayMemberPath + @"
""
SelectedValuePath=
""
" + SelectedValuePath + @"
""
SelectedValue=
""
{Binding Path=
" + SelectedValue + @"
, Mode=TwoWay}
""
ItemsSource=
""
{Binding Countries, Source={StaticResource CountriesList}}
""
/>
</DataTemplate>");
//, Mode=TwoWay
grdColumn =
new
GridViewDataColumn();
grdColumn.DataMemberBinding =
new
Binding(
"ContryName"
);
grdColumn.CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString());
grdColumn.Header =
"ContryName"
;
RadGridView1.Columns.Add(grdColumn);
Now Please do note that the itemssource resource is actually in my xaml page. It is not getting called at all by default. So I am explicitly assigning the itemssource to the combobox in the rowloaded event.
This thing is working fine when the data is getting loaded for the first time and the combobox is also coming filled with its data. But when I am selecting an item from the combobox. It is again recreating the celltemplate and thus I am loosing the data in the combobox.
Please do note that the itemssource of the datagrid and the itemssource of the combobox both implements inotifypropertychanged. And at present I am coding this in SL3. But in case required I can also try implementing this in SL4.
I hope I was clear about my problem. Any suggestions to fix this issue will be much appreciated.
Regards
Tiklu