Export (0) Print
Expand All

Binding.ValidationRules Property

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

Namespace:  System.Windows.Data
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public Collection<ValidationRule> ValidationRules { get; }
<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.

Property Value

Type: System.Collections.ObjectModel.Collection<ValidationRule>
A collection of ValidationRule objects.

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.

NoteNote

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.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft