I'd like to use the IDataErrorInfo, record-level, validation error icon to display errors returned from service calls which I make in the RecordUpdating event. This icon is normally associated with IDataErrorInfo support, but I cannot make the service calls via that support (i.e., IDataErrorInfo.Error getter) because that property getter is accessed much too frequently in XDG. For now, I've had to settle with displaying a MessageBox from RecordUpdating. It would be nice for the service errors to appear integrated with the built-in validation support.
This might not be possible, as it depends on how record-level IDataErrorInfo validation is implemented in XDG. One approach that works outside of XDG uses an hidden BindingExpression associated with the DataErrorValidationRule for a BindingGroup, and marks the BindingExpression as invalid, which forces the error message to display in the group's error icon. This is necessary because the error icon is bound to the group's Validation.Errors. This is but one idea, and it may be possible to do something like this in XDG, but it depends on how IDataErrorInfo validation is implemented in XDG.
I originally posted this question several months ago and have not received an answer. I'd like another analyst to try and help. Please do not refer me to the documentation on IDataErrorInfo, as I'm already quite familiar with it. I've also examined the relevant templates and nothing came to light. Serious help is appreciated.
Hello Darryl,
Thank you for your reply. I am very glad that you have managed to solve the issue that you were having. Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
I got a good answer for this from Stefan, but I gave you credit as well for a viable approach. Thanks for helping.
Thanks Krasimir. Actually, I need to enable the normal IDataErrorInfo support as well. I use that for simple field value checking, as opposed to the more resource-intensive service calls that can throw exceptions as well.
Thank you for your post. I have been reading through it and if I understand correctly, you are getting whether a record has validation errors, in the RecordUpdating event of the XamDataGrid and you wish to show that validation error, the same way that the XamDataGrid supports the IDataErrorInfo interface, without actually enabling the IDataErrorInfo support. if this is correct, I can suggest re-templating the RecordSelector and use the Tag property of the Record, to show and hide the error icon. You can set the visibility of the error icon to visible and add a trigger in the ContentTemplate that hides the icon if the Tag property of the record is null. In the RecordUpdating of InitializeRecord events, you can check the validation errors and if there are such errors to set e.Record.Tag to the error. I have created a sample application for you, that shows how you can implement this approach.
Please let me know if you need any further assistance on the matter.