Binding data with ComboBox in WPF

Data not showing in combo box

DataTable dt = new DataTable();
dt.Columns.Add("Code");
dt.Columns.Add("Name");
dt.Rows.Add("c1", "n1");
dt.Rows.Add("c2", "n2");
myCombo.ItemsSource = ((IListSource)dt).GetList();
myCombo.DisplayMemberPath = "Code";
myCombo.SelectedValuePath = "Name";
+3
source share
1 answer

instead of this line

myCombo.ItemsSource = ((IListSource)dt).GetList();

try using this

myCombo.ItemsSource = dt.DefaultView;
+7
source

Source: https://habr.com/ru/post/1764004/


All Articles