I have asked this in a past post, how would I pass the active DataRecord to the ValueConveter class using the COnverterParameter object. I have attached a sample project.
There are two numeric fields in the DataRecord - NumericVaue1 and NumericValue2. The ValueConverter I created will change the Foreground color of the NumericValue2 field.
If NumericValue2 > NumericValue1 Then Foreground color = Red
If NumericValue2 < NumericValue1 Then Foreground color = Green
If NumericValue 2 = NumericValue1 Then Foreground color = Black
I need the DataRecord to access NumericValue1 when applying the ValueConverter to NumericValue2. I get only the value of NumericValue2 passed to the ValueConverter class. There are other cases I need the DataRecord in the ValueConverter class to do similar comparisons on more than 1 field.
I even created a Dependancy Property in the ValueConverter class to try and bind the DataRecord but no luck.
I hope you can help. Thanks, Bob
I am sorry but I have had to move onto other things. I will look at your sample when I get back to this. Thank you for your help.
Bob
Hello Bob,
Please review the new sample I send you. There I try a new approach in setting the Style for the CellValuePresenter and now the values are colored in green/red/black all the time (including when the cell is in edit mode and when the record is hovered ). Regarding what you are saying for the style not applied to the “NewTotal” column I am still not able to see this issue, so I have also attached a video of the XamDataGrid with the applied styles, so I can be sure that we are working on the same thing.
I hope this suits your scenario better.
Yes the sample is similar but more closely matches what I am actually doing in my program using the EditModeEnding event to update the "New Total" field where I want the converter style applied. I have attached the same sample with the changes you suggested but it does not work as I wish it to work and I am beginning to think "wish" is the appropriate word.
The cell I changed has the style applied but the "New Total" field, even though the value has changed, does not have the style applied. A programatic change in a cells value does not seem to trigger what a user typed in change triggers and thus the style is not applied even though the value of "New Total" cell changes.
I have done what you suggested in other circumstances where I wanted the Selected records to have a style. But when the user clicked on a cell in a record it is "Active" but not "Selected" so I programtically set the record "IsSelected" = true in code but the IsSelected data trigger does not fire. So I have to create a data trigger for "IsActive" = true so the style is applied when the record is Active.
I am beginning to think that if I do something programatically the trigger for the cell styles will not be applied. Maybe there is a method or command that would fire these triggers and converters when data is changed programtically? I am going to see.
Excuse me for the misunderstanding,
The sample you are referring is very similar to the one I send you, so I was not sure if you have attached the sample you have in mind.
However thank you for the detailed description of the issue. I believe that if you set the same MultiBindings to the properties ForegroundActiveStyle, ForegraundHoverStyle you will have the desired functionality. If this still doesn’t suit your situation you can try handle the EditModeEnding or CellChanged event of the XamDataGrid and try manually changing the foreground color in the handler.
So where are we on this? Have you been able to understand my issue based on the sample and my explanation?