Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Validation.HasError Attached Property

Gets a value that indicates whether any binding on the target element has a validation error.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

See GetHasError
See Remarks

Property Value

Type: System.Boolean
true if any binding on the target element has a validation error; otherwise, false.

The Validation.HasError attached property does not have a conventional XAML usage in the form <object Validation.HasError="true" .../>. In WPF, data validation is sometimes performed with property triggers where Validation.HasError is used as a property condition to check the Property attribute value of a Trigger. Validation.HasError does appear in WPF XAML as an attribute value instead of the attribute. However, Silverlight does not use triggers in this capacity.

In Silverlight, handlers for events, such as SizeChanged, can check any pending error state. Such event handlers might check for the Validation.HasError attached property on objects in code, but would either call the GetHasError method or call the GetValue method with the HasErrorProperty identifier.

Handlers for the BindingValidationError event typically change to a particular VisualState for validation as part of their logic.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2015 Microsoft