1

I have a datagrid where I am implementing my own validation checks. When there is an error, I set the row's border to red and display a message to the user what the error is. However, in my datagrid, there is a red exclamation point that shows up as well. I was wondering if there is a way to hide this? I tried checking the Row.HasErrors() but that always returns false and Row.ClearErrors() won't remove the exclamation point either.

Eric R.
  • 1,105
  • 3
  • 21
  • 48

2 Answers2

4

Once the datagridrow got an error the exclamation mark does not go away even if you clear the error. In my case i did not need the row error since i am showing errors in the cell itself. So I used DataGrid.RowValidationErrorTemplate to never show the error.

<DataGrid.RowValidationErrorTemplate> <ControlTemplate> <TextBlock Text=""></TextBlock> </ControlTemplate> </DataGrid.RowValidationErrorTemplate>

Kathirk
  • 81
  • 2
  • That works. You can go a step further and omit the TextBlock as well.`` – Metalogic Sep 23 '18 at 19:52
  • If you are using `DataGridTextColumns` and for the Binding have `Mode=TwoWay` then try to remove it. In my case it solved the problem where the red exclamation mark never disappeared.. Here is my useful resource: https://stackoverflow.com/questions/5099039/wpf-datagrid-validation-errors-not-clearing – Stan1k Apr 01 '21 at 17:48
2

Have you checked out How to: Implement Validation with the DataGrid Control?

It depends a bit on exactly where the exclamation point is showing in the DataGrid. For example, if it on the row where the validation occurs you can implement your own DataGrid.RowValidationErrorTemplate or DataGrid.ValidationErrorTemplate.

There are quite a few examples for various situations in the link.

JayP
  • 809
  • 7
  • 9
  • Thanks for the link! I found some examples with creating my own template but the MSDN one you posted seems like the best working example. – Eric R. Dec 06 '11 at 12:50