BindingGroup.NotifyOnValidationError 属性

定义

获取或设置更改 Error 状态 ValidationRule 时是否发生该事件。

public:
 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

属性值

如果在更改状态时发生事件,则为 否则为 。 默认值为 false

示例

以下示例创建一个BindingGroup和集NotifyOnValidationErrortrue,以便应用程序可以在失败时Validation.Error处理ValidationRule事件。

<StackPanel.BindingGroup>
  <BindingGroup NotifyOnValidationError="True">
    <BindingGroup.ValidationRules>
      <src:ValidateDateAndPrice ValidationStep="ConvertedProposedValue" />
    </BindingGroup.ValidationRules>
  </BindingGroup>
</StackPanel.BindingGroup>

以下示例处理 Validation.Error 事件。

// This event occurs when a ValidationRule in the BindingGroup
// or in a Binding fails.
private void ItemError(object sender, ValidationErrorEventArgs e)
{
    if (e.Action == ValidationErrorEventAction.Added)
    {
        MessageBox.Show(e.Error.ErrorContent.ToString());
    }
}
' This event occurs when a ValidationRule in the BindingGroup
' or in a Binding fails.
Private Sub ItemError(ByVal sender As Object, ByVal e As ValidationErrorEventArgs)
    If e.Action = ValidationErrorEventAction.Added Then
        MessageBox.Show(e.Error.ErrorContent.ToString())

    End If
End Sub

注解

附加 Validation.Error 事件发生在具有 . 的 BindingGroup元素上。

适用于