,

Asynchronous and Composite Validation

Present since the Windows Phone 7.1 SDK is the INotifyDataErrorInfo interface, which is also present in Silverlight 4. This new API eliminates the need to rely on exceptions to indicate invalid property values. In addition, implementing INotifyDataErrorInfo makes it possible to evaluate the validity of a property on a secondary thread.

The INotifyDataErrorInfo interface contains three is used to determine whether the control contains validation errors. The GetErrors method returns all errors that are detected, and the ErrorsChanged event notifies listeners when an error has been added or removed from the set of known errors.

Image

FIGURE 26.10 INotifyDataErrorInfo interface is used to monitor input validation errors.

To enable validation using the INotifyDataErrorInfo interface, the binding expression’s NotifyOnValidationError property is set to true, as shown:

<TextBox Text="{Binding ValidatedString1, Mode=TwoWay,
                    NotifyOnValidationError=True}" />

The next section looks at implementing INotifyDataErrorInfo so that it can be reused across your entire app.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.76.234