Programmatically fire DataGrid.RowValidationRules

May 1, 2009 at 4:03 AM
Hello all,

Does anyone know how to get the grid to programmatically run all RowValidationRules? It seems to be the only way to get the ValidationErrorTemplate to appear.

My situation is: The user can change other fields in the UI which can cause the rows to be invalid. The row data implements IDataErrorInfo, so the data behind the row knows it's invalid; however the DataGridRow.ValidationErrorTemplate is not updated unless the DataGrid.RowValidationRules fire a ValidationRule which was triggered by a ValidationStep. So, I don't see the error template present unless the user begin/ends edit of a row to force the ValidationStep. I think this may also be a problem if you bind to an item source which already contains invalid IDataErrorInfo items; the grid won't show this.

Perhaps there is a way using Validation.MarkInvalid()?