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の状態が変化したときにValidationRule イベントが発生する場合は。それ以外の場合はfalse。 既定値は false です。

次の例では、BindingGroupを作成し、NotifyOnValidationErrorが失敗したときにアプリケーションがtrue イベントを処理できるように、Validation.ErrorValidationRuleに設定します。

<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を持つ要素で発生します。

適用対象