BindingGroup.NotifyOnValidationError Properti

Definisi

Mendapatkan atau mengatur apakah Error peristiwa terjadi saat status perubahan 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

Nilai Properti

true Error jika peristiwa terjadi ketika status ValidationRule perubahan; jika tidak, false. Defaultnya adalah false.

Contoh

Contoh berikut membuat BindingGroup dan mengatur NotifyOnValidationError ke true sehingga aplikasi dapat menangani Validation.Error peristiwa saat ValidationRule gagal.

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

Contoh berikut menangani peristiwa 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

Keterangan

Peristiwa Validation.Error terlampir terjadi pada elemen yang memiliki BindingGroup.

Berlaku untuk