How to configure a universal exception message "Value" cannot be converted "

I have a ComboBox associated with a property with a specific value and "due to some specific data state" the ComboBox does not contain any elements (ItemsSource is empty). The ComboBox attempts to find an element with a specific value using the binding to the SelectedValue Property of the ComboBox, which it does not find and displays the error message " The value" cannot be converted ".

A simplified example:

ID = 80; <ComboBox DisplayMemberPath="Value" SelectedValuePath="ID" SelectedValue="{Binding ID}"> <ComboBox.Items> </ComboBox.Items> </ComboBox> 

I am aware of the status of the ComboBox and I would like to configure this message for example, for example. localized value "The selected value cannot be found, check the accuracy of the records."

How can i do this?

+4
source share
1 answer

One way is to implement your own validation rule like this guy did . Or inherit from IDataErrorInfo as seen in this question and this .

+2
source

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


All Articles