I need to make row-level service calls that can have errors I'd like to incorporate into the DataPresenter's ErrorIcon display, just as with IDataErrorInfo errors. Anyone know how to manually add errors such that they will be displayed by this validation mechanism? My only option appears to be in the RecordUpdating event, and I'd like to be more elegant than MessageBox.Show().
Hello Darryl,
Thank you for your post. I have been looking into and I can suggest you see the sample in the Feature Browser under xamDataGrid / Display / IDataErrorInfo Support section, which shows hot to add ErrorInfo on Cell, Record or Record and Cell level. Please let me know if this helps you or I have misunderstood you in some way.
Looking forward for your reply.
I'd like to revive this thread since I've had time to look into it again. To reiterate, I'd like to use the IDataErrorInfo row-level validation support for resource-intensive validation calls that I cannot place in the IDataErrorInfo.Error() method because it is called too frequently. After some research, I found a way to do what I'd like, but I need some help accessing the validation rule XDG uses (and I assume it's a DataErrorValidationRule in a BindingGroup associated with the grid record).
Here's what I've found to work, given access to the validation rule (admittedly a hack, but worth it to me). I bind a property of the record viewmodel to an innocuous, invisible property in the element with the BindingGroup (in this case the TagProperty of a StackPanel), and create the error. For this to work with XDG, alll I need (I think) is to know how to access the ValidationRule associated with the XDG row-level IDataErrorInfo validation. I believe I could add an invisible field for the token binding expression I need to show the error. I'm open to other suggestions as well.
var error = new ValidationError(sp.BindingGroup.ValidationRules[0], spEmailer.GetBindingBLOCKED EXPRESSION;
Thanks Stefan. I've been combing through all IDataErroInfo related info for a few weeks and nothing comes to light on this. The samples and reference doc show how to style errors, but now how to inject errors into that framework.
If anything come to light later, I'll revisit this thread.