Binding.ValidationRules Binding.ValidationRules Binding.ValidationRules Binding.ValidationRules Property

Definition

Gets a collection of rules that check the validity of the user input.

public:
 property System::Collections::ObjectModel::Collection<System::Windows::Controls::ValidationRule ^> ^ ValidationRules { System::Collections::ObjectModel::Collection<System::Windows::Controls::ValidationRule ^> ^ get(); };
public System.Collections.ObjectModel.Collection<System.Windows.Controls.ValidationRule> ValidationRules { get; }
member this.ValidationRules : System.Collections.ObjectModel.Collection<System.Windows.Controls.ValidationRule>
Public ReadOnly Property ValidationRules As Collection(Of ValidationRule)

Property Value

A collection of ValidationRule objects.

Remarks

The WPF data binding model enables you to associate ValidationRules with your Binding or MultiBinding object. You can create custom rules by deriving from the ValidationRule class and implementing the Validate method, or you can use the built-in ExceptionValidationRule, which invalidates a value if there are exceptions during source updates.

The binding engine checks each ValidationRule associated with a binding each time an input value (the binding target property value) is transferred to the binding source property. For a detailed discussion of the validation process, see the Data Validation section in the Data Binding Overview.

Note

This property can be set in Extensible Application Markup Language (XAML) only by using the collection syntax shown, or by accessing the collection object and using its various methods, such as Add. The property to access the collection object is read-only, whereas the collection itself is read-write.

XAML Property Element Usage

<object>  
  <object.ValidationRules>  
    oneOrMoreValidationRules  
  </object.ValidationRules>  
</object>  

XAML Values

oneOrMoreValidationRules
One or more ValidationRule objects. You can use the ExceptionValidationRule class or create custom rules by subclassing the ValidationRule class.

Applies to

See also