Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
Data Validation in XAMDataGrid
posted

Hi,

I am working on an application which extensively uses XamDataGrid. We have recently started implementing data validations in our application. Below are the steps that we follow for validations in all our controls -

1.  Add a reference to System.ComponentModel.DataAnnotations.dll to the project – for adding annotations to the properties that we want to validate.

2.  Added Range/Required(or other) attribute to the properties of the domain object that need to be validated

3.  Implemented IDataErrorInfo interface in the class.

4.  Added IsValid Property to ViewModel which is set to true when there are no errors present in the screen. The setter of the property raises the CanExecuteChanged event of the Save button which has to be disabled in case of errors.

5.  Added ErrorChangedHandler in xaml.cs which tests if there are any errors and sets the IsValid property accordingly.

6. Added ValidatesOnExceptions=true, ValidatesOnDataErrors=true, NotifyOnValidationError=true in the Binding expressions for the controls to be validated.

7. Added SupportDataErrorInfo="RecordsAndCells" DataErrorDisplayMode="ErrorIconAndHighlight" to the FieldLayoutSettings of the XamDataGrid.

 

For normal controls this process works fine and the ErrorChangedHandler gets called. But this handler does not get called whenever an error occurs in the XAMDataGrid.

 

I have made a sample application. I have attached it.

If we change the value of the property in the grid in order to satisfy the range attribute, the error indication at the cell level gets removed but the error indication at the record level does not get removed.

 

Please take a look and let me know what needs to be done to get this working.

 

WpfApplication1.zip