I have a view model implementing INotifyDataErrorInfo. I am binding a textbox to one of the view model properties like this:
<TextBox Text="{Binding SelfAppraisal.DesiredGrowth, Mode=TwoWay, ValidatesOnNotifyDataErrors=True,NotifyOnValidationError=True}" Height="200"
TextWrapping="Wrap"/>
The data binding works, but the UI is not responding when I add validation errors like this:
// validation failed
foreach (var error in vf.Detail.Errors)
{
AddError(SelfAppraisalPropertyName + "." + error.PropertyName, error.ErrorMessage);
}
After running GetErrors("SelfAppraisal.DesiredGrowth") in the immidiate window, I can see:
Count = 1
[0]: "Must be at least 500 characters. You typed 4 characters."
I've made sure that the concatenation when adding an error matches the binding expression on the textbox, but the UI doesn't show messages as it was before I switched to using a complex type.
What am I doing wrong? Does validation with INotifyDataErrorInfo support this?
Update
My viewmodel, which implements INotifyDataErrorInfo does raise ErrorsChanged when adding/removing errors.
protected void RaiseErrorsChanged(string propertyName)
{
if (ErrorsChanged != null)
{
ErrorsChanged(this, new DataErrorsChangedEventArgs(propertyName));
}
}