c# - ComboBox SelectedItem Binding does not work -
i have datagrid 4 columns.
<datagrid itemsource="{binding mydataset,mode=twoway}"> <datagrid.columns> <datagridtemplatecolumn> <datagridtemplatecolumn.celltemplate> <datatemplate> <textblock ...../> </datatemplate> </datagridcolumn.celltemplate> </datagridtemplatecolumn> <datagridtemplatecolumn> <datagridtemplatecolumn.celltemplate> <datatemplate> <textblock ...../> </datatemplate> </datagridcolumn.celltemplate> </datagridtemplatecolumn> <datagridtemplatecolumn> <datagridtemplatecolumn.headertemplate> <datatemplate> ............. </datatemplate> </datagridtemplatecolumn.headertemplate> <datagridtemplatecolumn.celltemplate> <datatemplate> <combobox itemsource ="{binding firstcomboboxdata }" selecteditem="{binding firstcomboboxselectedval}"/> </datatemplate> </datagridcolumn.celltemplate> </datagridtemplatecolumn> <datagridtemplatecolumn> <datagridtemplatecolumn.celltemplate> <datatemplate> <datatemplate> <combobox itemsource ="{binding secondcomboboxdata }" selecteditem="{binding secondcomboboxselectedval}"/> </datatemplate> </datagridcolumn.celltemplate> </datagridtemplatecolumn> </datagrid.columns> </datagrid>
the model class mydata
in following.
class mydata : observableobject { private string _code; public string code { set { _code = value ; onpropertychanged("code");} { return _code ;} } private string _name; public string name { set { _name = value ; onpropertychanged("name");} { return _name ;} } private list<someotherclass> _firstcomboboxdata; public list<someotherclass> firstcomboboxdata { set { _firstcomboboxdata = value ; onpropertychanged("firstcomboboxdata");} { return _firstcomboboxdata ;} } private list<someotherclass> _secondcomboboxdata; public list<someotherclass> secondcomboboxdata { set { _secondcomboboxdata = value ; onpropertychanged("secondcomboboxdata");} { return _secondcomboboxdata ;} } private someotherclass _firstcomboboxselectedval; public someotherclass name { set { _firstcomboboxselectedval= value ; onpropertychanged("firstcomboboxselectedval");} { return _firstcomboboxselectedval;} } private someotherclass _secondcomboboxselectedval; public someotherclass secondcomboboxselectedval { set { _secondcomboboxselectedval= value ; onpropertychanged("secondcomboboxselectedval");} { return _secondcomboboxselectedval;} } } class someotherclass { private int id; public int id { set { id = value ; onpropertychanged("id");} { return id ;} } }
then have following list in viewmodel.
private observablecollection<mydata> _mydataset; public observablecollection<mydata> mydataset { set { _mydataset=value; onpropertychanged ("mydataset"); } { return _mydataset ;} }
i see fine. when change selected item of said comboboxes, mydataset
's relevant firstcomboboxselectedval
or secondcomboboxselectedval
not updated
have done wrong somewhere?
Comments
Post a Comment