diff --git a/Stylet/ValidatingModelBase.cs b/Stylet/ValidatingModelBase.cs index b361654..7374968 100644 --- a/Stylet/ValidatingModelBase.cs +++ b/Stylet/ValidatingModelBase.cs @@ -55,7 +55,7 @@ namespace Stylet } /// - /// Validate all properties. If you override this, you MUST fire ErrorsChanged as appropriate, and NotifyOfPropertyChange(() => this.HasErrors) if appropriate + /// Validate all properties. If you override this, you MUST fire ErrorsChanged as appropriate, and call ValidationStateChanged /// protected virtual async Task ValidateAsync() { @@ -80,7 +80,7 @@ namespace Stylet } if (anyChanged) - this.NotifyOfPropertyChange(() => this.HasErrors); + this.OnValidationStateChanged(); } /// @@ -93,7 +93,7 @@ namespace Stylet } /// - /// Validate a single property, by name. If you override this, you MUST fire ErrorsChange and NotifyOfPropertyChange(() => this.HasErrors) if appropriate + /// Validate a single property, by name. If you override this, you MUST fire ErrorsChange and call OnValidationStateChanged() if appropriate /// /// Property to validate protected virtual async Task ValidatePropertyAsync(string propertyName) @@ -112,7 +112,7 @@ namespace Stylet var handler = this.ErrorsChanged; if (handler != null) handler(this, new DataErrorsChangedEventArgs(propertyName)); - this.NotifyOfPropertyChange(() => this.HasErrors); + this.OnValidationStateChanged(); } } @@ -126,6 +126,14 @@ namespace Stylet await this.ValidatePropertyAsync(propertyName); } + /// + /// Called whenever the error state of any properties changes. Calls NotifyOfPropertyChange(() => this.HasErrors) by default + /// + protected virtual void OnValidationStateChanged() + { + this.NotifyOfPropertyChange(() => this.HasErrors); + } + /// /// Gets the validation errors for a specified property or for the entire entity. ///