I have a ComboBox bound to a property with a specific value
and “due to some specific state of data” the ComboBox doesn’t contain
any items (ItemsSource is empty).
The ComboBox tries to find an item with the specific value using a Binding on
SelectedValue property of the ComboBox, which it doesn’t find
and displays an error “Value ” could not be converted“.
Simplified example:
ID = 80;
<ComboBox DisplayMemberPath="Value"
SelectedValuePath="ID"
SelectedValue="{Binding ID}">
<ComboBox.Items>
</ComboBox.Items>
</ComboBox>
I am aware of the state of the ComboBox and I would like to customize this message
somehow eg. localized value of “The selected value could not be found, verify validity of the entries”.
How can I accomplish that?
One way is to implement your own Validation Rule like this guy did . Or inherit from IDataErrorInfo as seen in this question and this one.