Silverlight - INotifyDataErrorInfo and complex property binding

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:

// validation failed
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));
        }
    }
+5
1

TextBox SelfAppraisal . , SelfAppraisal. SelfAppraisal:

foreach (var error in vf.Detail.Errors)
{
    SelfAppraisal.AddError(error.PropertyName, error.ErrorMessage);
}

, SelfAppraisal. TextBox DesiredGrowth, .

, , TextBox SelfAppraisal.DesiredGrowth.

: ViewModel . :

public string SelfAppraisalDesiredGrowth
{
    get { return SelfAppraisal != null ? SelfAppraisal.DesiredGrowth : null; }
    set
    {
        if (SelfAppraisal == null)
        {
            return;
        }

        if (SelfAppraisal.DesiredGrowth != value)
        {
            SelfAppraisal.DesiredGrowth = value;
            RaisePropertyChanged("SelfAppraisalDesiredGrowth");
        }
    }
}

:

<TextBox Text="{Binding SelfAppraisalDesiredGrowth, Mode=TwoWay, ValidatesOnNotifyDataErrors=True,NotifyOnValidationError=True}"  Height="200" TextWrapping="Wrap"/>

VM :

// validation failed
foreach (var error in vf.Detail.Errors)
{
    AddError(SelfAppraisalPropertyName + error.PropertyName, error.ErrorMessage);
}
+2

All Articles