I have a view model that implements INotifyDataErrorInfo. I bind a text field to one of the properties of the view model, for example:
<TextBox Text="{Binding SelfAppraisal.DesiredGrowth, Mode=TwoWay, ValidatesOnNotifyDataErrors=True,NotifyOnValidationError=True}" Height="200"
TextWrapping="Wrap"/>
Data binding works, but the user interface is not responding when I add validation errors as follows:
foreach (var error in vf.Detail.Errors)
{
AddError(SelfAppraisalPropertyName + "." + error.PropertyName, error.ErrorMessage);
}
After starting GetErrors("SelfAppraisal.DesiredGrowth")in the immidiate window, I see:
Count = 1
[0]: "Must be at least 500 characters. You typed 4 characters."
I made sure that the concatenation when adding an error matches the binding expression in the text box, but the user interface does not display a message, as it was before I switched to using a complex type.
What am I doing wrong? Does this support with INotifyDataErrorInfo?
Update
My viewmodel, INotifyDataErrorInfo, ErrorsChanged / .
protected void RaiseErrorsChanged(string propertyName)
{
if (ErrorsChanged != null)
{
ErrorsChanged(this, new DataErrorsChangedEventArgs(propertyName));
}
}