Hello all,
I have a xamDataGrid with N number of objects. Any one of my objects can be set as the "Base Line" object which is a property in my ViewModel. In a DataGrid column I would like for any values that are not equal to the Base Line's value, to change the color. This will allow the user to see all changes from the base line very easily. Is there DataTrigger support that can handle this dynamic problem?
Thanks,
KP
The tricky part in my case is there is no common comparison (ie. 1 property). Each cell needs to evaluate itself independently based on the same field in the base object.
I do realize however that I'm going beyond the help of the control itself. You gave me great information here, greatly appreciated.
Hello Kevin,
I have been looking into your last reply and if I understand correctly you want to avoid casting the items in values array of the Convert method of the Converter to a particular object type. If so, I can suggest your objects in the model to implement IComparable interface an in the Convert method of the Converter class you can cast the objects in the values array to IComparable and call CompareTo method in which you can implement the logic that will compare your objects. By doing so the Converter does not need to know anything about the model, it needs to know whether the objects implement IComparable interface. I am attaching the sample application that I sent you with my previous reply in order to implement the above approach.
If you need any further assistance please do not hesitate to ask.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hello Krasimir,
Thanks for your detailed response. That solution seems to work very well, but it will break my MVVM design. Do you know of a way to do the same and keep the converter from knowing anything about the model?
I'm using MVVM light.
Kevin
Hello,
I have created a sample application that demonstrates an approach for implementing the functionality that you are looking for. The approach uses a Style with an DataTrigger for the CellValuePresenter. The DataTrigger’s Binding property is set to a MultiBindig object which contains two Binding objects. The first is Binding to the BaseLine propery and the second is to Record.DataItem of the CellValuePresenter. In the Convert method of MultiValueConverter is calculated whether the value of the Record.DataItem is equal to the BaseLine.
If you need any further assistance on this please do not hesitate to ask me.