So, I have a customer table containing customer records, a record, each of which has a customertype field. I also have a customertype table containing valid values for the customertype field.
And I need WPF to do CRUD. (Create, view, update, delete).
The obvious solution is to use a ComboBox with the SelectedValue property associated with the customertype field, and its ItemsSource property is tied to the list populated by the customertype table query.
The problem is that this does not work, except for the simple problem that you see in the exercises.
The difficulty arises when viewing or editing a customer record that has a customertype value that is not in the customertype table. This can happen by mistake, or it can happen because the customertype type is deprecated and removed from the table.
In this case, WPF does this to set the customertype field to null, because SelectedValue is not in the ItemsSource list. And that is the problem.
If you are just browsing, you should see the value that is in the table, regardless of whether it is in the list. If you are editing, you can make a reasonable argument that you should also show the value that is in the table, at least initially, but if you change the selection, you will not be able to get where you started.
, - ? , /, , -, . ( , XAML, , XAML I, , .)