Foundation series four wpf_MVVM_004 query data is bound to the drop-down box

Drop-down boxes to query data binding:
(1): Example of the Model
(2): LINQ query data, convert format list;
(3): Get Name value drop-down box, drop-down box binding
example:
(1): myEntitys, myModel myEntitys new new = ();
(2): var myList = myModel.Table1.ToList ();
(. 3):
myComboBox.ItemsSource = myList;
myComboBox.DisplayMemberPath = "is a field in the drop-down box";
myComboBox.SelectedValuePath = " It is hidden in the drop-down box field ";

Note: Get value myComboBox dropdown: myComboBox.SelectedValue,
at this time, the current value of the drop down box, "is hidden in the drop-down box field" = myComboBox.SelectedValue;

Published 130 original articles · won praise 36 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_44548307/article/details/104756055