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

屬性值

true 若事件 Error 發生於 a ValidationRule 的狀態變化時;否則, false。 預設值為 false

範例

以下範例建立 aBindingGroup,並將 設為 NotifyOnValidationErrortrue使應用程式能在 a Validation.Error 失敗時處理該ValidationRule事件。

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

下列範例會處理 Click 事件。

// 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元素上。

適用於