user2190492
user2190492

Reputation: 1202

Does binding engine also call INotifyDataErrorInfo GetErrors() when ErrorsChanged event is not invoked by viewmodel?

I've got a viewmodel that implements the INotifyDataErrorInfo interface.

When a property is updated and a validation error occurs, I call the ErrorsChanged event, the binding engine then knows it has to call the GetErrors(string propertyName) method on my viewmodel, and from there I return the IEnumerable of errors for the corresponding propertyName. Nothing special.

But when I was debugging, it seems to be that the GetErrors() method is called when a viewmodel property changes (on invoking INotifyPropertyChanged.PropertyChanged of course). Even while my viewmodel didn't invoke ErrorsChanged.

Does the binding engine call GetErrors() on its own when a property change is notified? (And thus not only when my viewmodel explicitly invokes ErrorsChanged?)

I can't find it in the docs.

Upvotes: 0

Views: 215

Answers (1)

mm8
mm8

Reputation: 169420

Does the binding engine call GetErrors() on its own when a property change is notified? (And thus not only when my viewmodel explicitly invokes ErrorsChanged?)

Yes. The TransferValue method, which eventually get called when you raise a PropertyChanged event for a UI bound source property, in the BindingExpression class calls UpdateNotifyDataErrors as you can see in the source code.

Upvotes: 1

Related Questions