There seems to be a bug in WPF 4.0 DataGrids.
I'm implementing IDataErrorInfo
on my objects, and I have an ObservableCollection
that a datagrid binds to. I have ValidatesOnDataErrors=True
set on the columns but nothing set on the rows. I have UpdateSourceTrigger="PropertyChanged"
The validation works perfectly on a cell by cell level. However, when you leave a cell invalid, go to any other cell and then return to the invalid cell and enter in valid data, the cell becomes valid but the row remains invalid when it should be valid.
In general property validation, it will be validated once the source gets updated but in the case of a RowValidation
you need to specify the RowValidationRule
to perform the RowValidation
.
<DataGrid.RowValidationRules>
<DataErrorValidationRule ValidatesOnTargetUpdated="True" ValidationStep="UpdatedValue" />
</DataGrid.RowValidationRules>
Now the DataGrid
will validates for the Rows also you can provide the RowValidationErrorTemplate
to show the Error in Custom format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With