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)

使用指定的 BindingExpression 物件,將指定的 ValidationError 物件標記為無效。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

當繫結項目遇到驗證錯誤,但只在繫結有設定為 trueNotifyOnValidationError 值時發生。Occurs when the bound element runs into a validation error, but only for bindings with the NotifyOnValidationError value set to true.

適用於

另請參閱