Binding.NotifyOnValidationError 属性


获取或设置一个值,该值指示是否对绑定对象引发 Error 附加事件。Gets or sets a value that indicates whether to raise the Error attached event on the bound object.

 property bool NotifyOnValidationError { bool get(); void set(bool value); };
public bool NotifyOnValidationError { get; set; }
member this.NotifyOnValidationError : bool with get, set
Public Property NotifyOnValidationError As Boolean



如果在源更新过程中出现验证错误时应对绑定对象引发true 附加事件,则为 Error ;否则为 falsetrue if the Error attached event should be raised on the bound object when there is a validation error during source updates; otherwise, false. 默认值为 falseThe default is false.


如果绑定 ValidationRules 与它相关联,则每次将目标属性值传输到 source 属性时,绑定引擎都会检查每个规则。If the binding has ValidationRules associated with it, the binding engine checks each rule each time it transfers the target property value to the source property. 如果规则使某个值失效,则绑定引擎将创建一个 ValidationError 对象并将其添加到中 ValidationErrorsIf a rule invalidates a value, the binding engine creates a ValidationError object and adds it to the Validation.Errors 绑定对象的集合。collection of the bound object. 如果该 Validation.Errors 属性不为空,则 Validation.HasError 对象的附加属性将设置为 trueWhen the Validation.Errors property is not empty, the Validation.HasError attached property of the object is set to true. 如果将 NotifyOnValidationError 的属性 Binding 设置为 true ,则绑定引擎将 Validation.Error 在对象上引发附加事件。If the NotifyOnValidationError property of the Binding is set to true, then the binding engine raises the Validation.Error attached event on the object.

有关验证过程的详细讨论,请参阅 数据绑定概述中的 "数据验证" 一节。For a detailed discussion of the validation process, see the Data Validation section in the Data Binding Overview.