Welcome to Xceed DataGrid for Silverlight > Manipulating Data > Editing and Inserting Data > Validation |
Xceed DataGrid for Silverlight takes full advantage of the INotifyDataErrorInfo and IDataErrorInfo support provided by the Silverlight binding engine. Therefore, if the underlying business objects implement either interface, the grid will be notified of any errors and a visual cue will be displayed indicating which item and fields (i.e., row and cell, respectively) are in error. A tooltip containing the exact error message will also be displayed if the mouse hovers over a row or cell that contains invalid data. If more than one validation error occurred, the first one found will be displayed.
Both the EditableRow and EditableCell classes and their derivatives expose various properties that can be used to retrieve the validation errors that occur and customize how they are displayed. When the content of one or more cells fails the validation process, the HasValidationErrors properties will return true and the ValidationErrors properties will contain the errors that occurred. The HasRestrictiveValidationErrors properties indicate whether the validation error that occurred prevents the focus from moving to another row until the error is fixed. Usually, all errors are restrictive; however, validation errors reported through INotifyDataErrorInfo and IDataErrorInfo are considered non-restrictive.
The ValidationState property can also be queried to determine whether the row or cell is in a valid or invalid state. The ValidationState property of a row will return Invalid if one of its cells is in an invalid state even if the row itself does not have validation errors.
Unless they are returned by the INotifyDataErrorInfo implementation, the validation errors that occur at the cell level will not be contained in the parent row's ValidationErrors collection. |
To customize how the validation errors are displayed in the tooltip that is displayed when the mouse hovers over a row or cell that contains invalid data, the ValidationErrorToolTip and ValidationErrorToolTipContentTemplate properties can be used.
For more information and examples on validation, refer to the Local Validation and Server-Side Validation sample applications. |