Hello,
I have a custom Error Class that utilizes IErrorContainer and INotifyDataErrorInfo. It has a Severity enum Property that indicates whether it is an error or warning. Now Based on this property i want to change Cell appearance of XamDataGrid. I tried to use DataTemplate but couldn't different appearance. Is it possible in XamDataGrid? Do You have any example of such functionality?
Hello Adam,
I have been investigating into the behavior you are looking to achieve, and it appears that the bindings that you have attached to the Conditions in your MultiDataTriggers are not valid. The data context of the Condition in this case will be the editor. As such, if you are looking to bind to your underlying data item in this case, you will need to bind to DataContext.DataItem.<propertyName>.
I am attaching a sample project to demonstrate the above.
Please let me know if you have any other questions or concerns on this matter.
XamDataGridIDataErrorInfo.zip
Hello Andrew,
Thanks for fast response, unfortunately the example that You have sent does not solve my issue. What i want to achieve is to override IErrorConatiner Erorrs Collection with one that contains Dictionary<string(PropertyName), IEnumerable<IError>(custom object that contains information whether it is a warning or error)> and based on this information i want change appearance of cells border Yellow for warning and red for errors. Is such scenario also possible ? I want this mechanism to be reused by all XamDataGrid based editors.
It looks like I had a sample of a similar name to the description of this issue that wasn’t actually the sample I built for the template that you provided. I am attaching the correct sample that uses a slightly modified version of the DataTemplate you originally provided to show a different color based on an enum that determines whether or not the error is a warning or not.
My apologies for the inconvenience. Please let me know if you have any other questions or concerns on this matter.
XDGDataErrorInfoTemplateDemo.zip
Unfortunately Your example covers much simpler scenario.
In my Case i have a private readonly Dictionary<string(PropertyName), IEnumerable<IError>(custom object that contains information whether it is a warning or error)> so multiple property can have multiple errors with different severities and in Your Example severity is Property of a RowViewModel so if we would have two Properties with errors of different severity we would not be able to distinguished which one is which.
Visualization of my problem:
Thank you for your update on this matter.
I am curious to know if the Dictionary route that you are following is actually triggering the default IDataErrorInfo support of the XamDataGrid? I ask this because if it does not, then re-templating the DataErrorContentTemplateKey will not help you in this case because that template will not become visible as a result of changes to your dictionary.
I am also not entirely sure I understand how you are integrating this with the IDataErrorInfo interface? As such, I will request that you please provide an isolated sample project that demonstrates the behavior you are using with the Dictionary to represent your errors, or modify mine such that it uses this behavior and send it back?