Edit

Share via


BindingGroup.NotifyOnValidationError Property

Definition

Gets or sets whether the Error event occurs when the state of a ValidationRule changes.

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

Property Value

true if the Error event occurs when the state of a ValidationRule changes; otherwise, false. The default is false.

Examples

The following example creates a BindingGroup and sets NotifyOnValidationError to true so that the application can handle the Validation.Error event when a ValidationRule fails.

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

The following example handles the Validation.Error event.

// 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

Remarks

The Validation.Error attached event occurs on the element that has the BindingGroup.

Applies to