As per a previous post, how do you do data validation in WPF using IDataErrorInfo?
Well what does IDataErrorInfo give you? It defines two properties:
public string Error
{
get;
}
public string this[string columnName]
{
get;
}
When you implement these, you provide error validation for your WPF application.
How does that happen?
Well, it doesn’t automatically of course [no surprises there].
When you specify your binding in xaml, you need to specify either the ValidationRules element or the ValidatesOnDataErrors parameter:
<Binding Source=”{StaticResource tradeList}” Path=”Instrument” UpdateSourceTrigger=”PropertyChanged”>
<Binding.ValidationRules>
<DataErrorValidationRule>
</Binding.ValidationRules>
</Binding>
or
<Binding Source=”{StaticResource tradeList}” Path=”Instrument” ValidatesOnDataErrors=”true” />