この記事は機械翻訳されています。英語版の記事を表示するには、[英語] のチェック ボックスをオンにしてください。また、テキストにマウス ポインターを合わせると、ポップアップ ウィンドウに英語のテキストを表示することもできます。
翻訳
英語

Validation.Errors 添付プロパティ

 

公開日: 2016年10月

バインドされている要素のアクティブなすべての ValidationError オブジェクトのコレクションを取得します。

名前空間:   System.Windows.Controls
アセンブリ:  PresentationFramework (PresentationFramework.dll 内)

See GetErrors

プロパティ値

Type: System.Collections.ObjectModel.ReadOnlyObservableCollection<ValidationError>

バインドされている要素のアクティブなすべての ValidationError オブジェクトの読み取り専用コレクション。 既定値は空のコレクションです。

The application cannot modify the content of this collection. See the Example section for an example of how to use this attached property.

The TLA2#tla_winclient data binding model enables you to associate P:System.Windows.Data.Binding.ValidationRules with your T:System.Windows.Data.Binding object. Validation occurs during binding target-to-binding source value transfer before the converter is called. The following describes the validation process:

  1. When a value is being transferred from the target property to the source property, the data binding engine first removes any T:System.Windows.Controls.ValidationError that may have been added to the P:System.Windows.Controls.Validation.Errors attached property of the bound element. It then checks if there are any custom T:System.Windows.Controls.ValidationRules defined for that T:System.Windows.Data.Binding, in which case it calls the M:System.Windows.Controls.ValidationRule.Validate(System.Object,System.Globalization.CultureInfo) method on each of the T:System.Windows.Controls.ValidationRules until one of them runs into an error or until all of them pass.

  2. Once there is a custom rule that does not pass, the binding engine creates a T:System.Windows.Controls.ValidationError object and adds it to the P:System.Windows.Controls.Validation.Errors collection of the bound element. When P:System.Windows.Controls.Validation.Errors is not empty, the P:System.Windows.Controls.Validation.HasError attached property of the element is set to true. Also, if the P:System.Windows.Data.Binding.NotifyOnValidationError property of the T:System.Windows.Data.Binding is set to true, then the binding engine raises the E:System.Windows.Controls.Validation.Error attached event on the element.

  3. If all of the rules pass, the binding engine then calls the converter, if one exists.

  4. If the converter passes, the binding engine calls the setter of the source property.

  5. If the binding has an T:System.Windows.Controls.ExceptionValidationRule associated with it and an exception is thrown during step 4, the binding engine checks to see if there is a P:System.Windows.Data.Binding.UpdateSourceExceptionFilter. You have the option to use the P:System.Windows.Data.Binding.UpdateSourceExceptionFilter callback to provide a custom handler for handling exceptions. If an P:System.Windows.Data.Binding.UpdateSourceExceptionFilter is not specified on the T:System.Windows.Data.Binding, the binding engine creates a T:System.Windows.Controls.ValidationError with the exception and adds it to the P:System.Windows.Controls.Validation.Errors collection of the bound element.

Also note that a valid value transfer in either direction (target-to-source or source-to-target) clears the T:System.Windows.Controls.Validation.P:System.Windows.Controls.Validation.Errorsattached property.

For information about the behavior of this property in T:System.Windows.Data.MultiBinding scenarios, see P:System.Windows.Data.MultiBindingExpression.ValidationError.

For more information, see "Data Validation" in Data Binding Overview.

See Remarks. The P:System.Windows.Controls.Validation.Errors collection itself is not user settable, but you can use it in a control template definition in TLA2#tla_xaml.

Identifier field

ErrorsProperty

Metadata properties set to true

IsNotDataBindable

トップに戻る
表示: