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.
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.
18.217.92.209