Validation 类

定义

提供支持数据验证的方法和附加属性。Provides methods and attached properties that support data validation.

public ref class Validation abstract sealed
public static class Validation
type Validation = class
Public Class Validation
继承
Validation

注解

有关验证过程的详细讨论,请参阅 数据绑定概述中的 "数据验证"。For a detailed discussion of the validation process, see "Data Validation" in Data Binding Overview.

字段

ErrorEvent

标识 Error 附加事件。Identifies the Error attached event.

ErrorsProperty

标识 Errors 附加属性。Identifies the Errors attached property.

ErrorTemplateProperty

标识 ErrorTemplate 附加属性。Identifies the ErrorTemplate attached property.

HasErrorProperty

标识 HasError 附加属性。Identifies the HasError attached property.

ValidationAdornerSiteForProperty

标识 ValidationAdornerSiteFor 附加属性。Identifies the ValidationAdornerSiteFor attached property.

ValidationAdornerSiteProperty

标识 ValidationAdornerSite 附加属性。Identifies the ValidationAdornerSite attached property.

附加属性

Errors

获取绑定元素上所有活动 ValidationError 对象的集合。Gets the collection of all active ValidationError objects on the bound element.

ErrorTemplate

获取或设置用于在装饰器层上生成验证错误反馈的 ControlTemplateGets or sets the ControlTemplate used to generate validation error feedback on the adorner layer.

HasError

获取一个值,该值指示绑定目标元素上的任一绑定是否具有 ValidationErrorGets a value that indicates whether any binding on the binding target element has a ValidationError.

ValidationAdornerSite

获取或设置元素,该元素似乎可指示在设置此属性的绑定元素上出现了验证错误。Gets or sets the element that appears to indicate that a validation error occurred on the bound element where this property is set.

ValidationAdornerSiteFor

获取或设置元素,此元素似乎为其指示发生了错误。Gets or sets the element for which this element appears to indicate that an error occurred.

方法

AddErrorHandler(DependencyObject, EventHandler<ValidationErrorEventArgs>)

向指定对象添加 Error 附加事件的事件处理程序。Adds an event handler for the Error attached event to the specified object.

ClearInvalid(BindingExpressionBase)

从指定的 ValidationError 对象中移除所有 BindingExpressionBase 对象。Removes all ValidationError objects from the specified BindingExpressionBase object.

GetErrors(DependencyObject)

获取指定元素的 Errors 附加属性的值。Gets the value of the Errors attached property of the specified element.

GetErrorTemplate(DependencyObject)

获取指定元素的 ErrorTemplate 附加属性的值。Gets the value of the ErrorTemplate attached property of the specified element.

GetHasError(DependencyObject)

获取指定元素的 HasError 附加属性的值。Gets the value of the HasError attached property of the specified element.

GetValidationAdornerSite(DependencyObject)

获取指定元素的 ValidationAdornerSite 附加属性值。Gets the value of the ValidationAdornerSite attached property for the specified element.

GetValidationAdornerSiteFor(DependencyObject)

获取指定元素的 ValidationAdornerSiteFor 附加属性值。Gets the value of the ValidationAdornerSiteFor attached property for the specified element.

MarkInvalid(BindingExpressionBase, ValidationError)

使用指定 ValidationError 对象将指定 BindingExpression 对象标记为无效。Marks the specified BindingExpression object as invalid with the specified ValidationError object.

RemoveErrorHandler(DependencyObject, EventHandler<ValidationErrorEventArgs>)

从指定对象添加 Error 附加事件的事件处理程序。Adds an event handler for the Error attached event from the specified object.

SetErrorTemplate(DependencyObject, ControlTemplate)

ErrorTemplate 附加属性的值设置为指定的元素。Sets the value of the ErrorTemplate attached property to the specified element.

SetValidationAdornerSite(DependencyObject, DependencyObject)

ValidationAdornerSite 附加属性设置为指定元素上的指定值。Sets the ValidationAdornerSite attached property to the specified value on the specified element.

SetValidationAdornerSiteFor(DependencyObject, DependencyObject)

ValidationAdornerSiteFor 附加属性设置为指定元素上的指定值。Sets the ValidationAdornerSiteFor attached property to the specified value on the specified element.

附加事件

Error

在绑定元素遇到验证错误时发生,但仅针对 NotifyOnValidationError 值设置为 true 的绑定。Occurs when the bound element runs into a validation error, but only for bindings with the NotifyOnValidationError value set to true.

适用于

另请参阅