I have always struggled with those comboBox properties
- DisplayMemberPath
- SelectedValue
- SelectedValuePath
I am building a master detail form .
- ComboBox filled with Customers
- User Selects a Customer in Combo
- All the textBoxes EG Fills correctly
The problem I am having I have made it work but I don’t understand those properties and the differences.
Is there a noddy example explaining what they do?
I think we can understand this better with an example. See this class:
and the following xaml:
DisplayMemberPathpoints to theNameproperty, so the value displayed in theComboBoxand theEmployeeentries contained in the drop down list, will be theNameproperty of theEmployeeobject.To understand the other two, you should first understand
SelectedItem.SelectedItemwill return the currently selectedEmployeeobject from theComboBox. You can also assignSelectedItemwith anEmployeeobject to set the current selection in theComboBox.SelectedValuePathpoints toId, which means you can get theIdof currently selectedEmployeeby usingSelectedValue. You can also set the currently selectedEmployeein theComboBoxby setting theSelectedValueto anId(which we assume will be present in theEmployeeslist).