WPF Combobox binding to DataTable not working -


combobox defined as

<combobox name="cmbcallsource" /> 

at form load run code (i checked dtsources datatable ends proper contents in debugger):

//init source list         dtsources = new datatable();         dtsources.columns.add(new datacolumn("key", type.gettype("system.int32")));         dtsources.columns.add(new datacolumn("caption", type.gettype("system.string")));         dtsources.rows.add(new object[] { -1, utility.getstringbykey("string1") }); ;         dtsources.rows.add(new object[] { 0, utility.getstringbykey("string2") }); ;         dtsources.rows.add(new object[] { 1, utility.getstringbykey("string3") }); ;         dtsources.rows.add(new object[] { 2, utility.getstringbykey("string4") }); ;         dtsources.rows.add(new object[] { 3, utility.getstringbykey("string5") }); ;         dtsources.rows.add(new object[] { 4, utility.getstringbykey("string6") }); ;          //attempt 1         cmbcallsource.datacontext = dtsources.defaultview;         cmbcallsource.selectedvaluepath = "key";         cmbcallsource.displaymemberpath = "caption";          //attempt 2         //binding mybinding = new binding("name");         //mybinding.source = dtsources; // data source example          //cmbcallsource.displaymemberpath = "caption";         //cmbcallsource.selectedvaluepath = "key";         //cmbcallsource.setbinding(combobox.itemssourceproperty, mybinding);  

i tried both ways (second 1 commented out). combobox ends empty either way. missing here?

set itemsource property, not datacontext

cmbcallsource.itemssource = dtsources.defaultview; 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -