WPF: Detect row validation errors in C# code

后端 未结 3 715
借酒劲吻你
借酒劲吻你 2021-01-06 07:29

I want to achieve a pretty simple task, but none of the solutions here on SO or otherwise found have helped me so far:

I have a WPF DataGrid, which is b

3条回答
  •  不要未来只要你来
    2021-01-06 08:12

    Why dont you catch the attached bubbling routed event Validation.Error on your data grid?

      
    

    Make sure you have NotifyOnValidationError=true in your bindings. This way you would know that error has been raised and show that in your messagebox.

    But do you really "know" there are errors on the datagrid? I mean do you see the errors highlighted using red border , tooltips, row validation error template etc? Isnt that sufficient to indicate to user?

    Cant you use

      Validation.GetHasError(mydataGrid)
    

    to check if its in error?

提交回复
热议问题