BindingGroup.NotifyOnValidationError Proprietà

Definizione

Ottiene o imposta un valore che indica se l’evento Error viene generato al modificarsi dello stato di un oggetto 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

Valore della proprietà

true se l’evento Error viene generato al modificarsi dello stato di un oggetto ValidationRule; altrimenti, false. Il valore predefinito è false.

Esempio

L'esempio seguente crea un BindingGroup oggetto e imposta NotifyOnValidationError su true in modo che l'applicazione possa gestire l'evento Validation.Error quando un ValidationRule errore.

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

Nell'esempio seguente viene gestito l'evento 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

Commenti

L'evento Validation.Error collegato si verifica sull'elemento BindingGroupcon .

Si applica a