We have implemented the INotifyDataErrorInfo in our view model and are able to see the error messages in the cells for a row that is in edit mode. This works fine for validations that are triggered when we tab out of cells and so on. The controls are highlighted with the error message.
However, we do some of the validations upon a button click for all selected rows and validation is also performed on the server. Upon return of data from the server, the event is raised and we can see the framework calling into GetErrors(), but the errors do not show up. We have attempted to modify the ItemTemplate control (usually a TextBox) with the
NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnNotifyDataErrors=True
on the textbox's binding. But this does not show the errors on the ItemTemplate. Is this functionality only available on the EditorTemplate?
This is not optimal because the user won't see any errors until they click on that row, so in fact may not know they are there?
Is there a way to get this to work? Is there an alternative or work-around?
Hi,
Were you able to get this to work, or do you have further questions?
Here is the sample I used to test it.
Hope this helps,
I have just tested this and the validation UI elements are displayed. Must be some other setting that is preventing validation.
Regards,
It does not seem to work for a TextBox with IsReadOnly="True" in an <ItemTemplate>.
basically the validation UI elements(the red border and popup with the error message) comes from the bound control. In this case the TextBlock does not support validation messages in contrast with the TextBox control.
So you need to use an element which supports Validation in the ItemTemplate. You could probably re-style the TextBox or create a custom control to display the validation errors.