I have a XamGrid that has a custom conditional/background that highlights cells with today's date (see first screen shot). When I sort a column in the grid, this background highlighting disappears (see second screen shot). If I then click on any cell of the grid all of the background highlights reappear.
Any idea what might be causing this type of behavior on sort?
Second screenshot:
Hello Gary,
Thank you for your post. I have been looking into your question and depending on the approach that you are using for highlighting the cells of the XamGrid, it is possible that it is caused by the virtualization of the XamGrid’s CellControls. For example, if you set the Background property of the CellControl in code, for example in the Loaded event of the CellControl, when the CellControl is reused for another Cell, that does not have the current date for value, the cell will be highlighted or if a CellControl used for a non-highlighted cell is reused for a cell that is supposed to be highlighted, you will get the result that you refer.
If your goal is to highlight the cells that has DateTime.Now as value, I can suggest using ConditionalFormatting. You can use EqualsToConditionalFormattingRule that has Value set to DateTime.Now and set the StyleToApply to a style that will make the background red. Also, using ConditionaFormatting, you can set the StyleScope to Cell or Row, based on whether you wish to apply the style only for the cells in the given Column or the whole row.
I have created a sample application for you, that shows how you can use the conditional formatting.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
Hi Krasimir, I am using the conditional formatting mechanism, although, I create my own formatter in a code behind and have to define a more elaborate style for ConditionalFormattingCellControl due to the need to change mouse-over highlighting. Your example works out of the box, so I changed it to be closer to what I have set up and see the same problem described before. Attached is the updated sample - note that clicking on the grid makes the highlighting reappear after a sort. I don't know if this behavior is due to my extensive style overload of the ConditionalFormattingCellControl or some other issue?
Thank you for your post and the sample application. I have been investigating the issue and it seems that it is caused by setting the Template (re-tempalting) of the ConditinalFormattingCellControl. I have logged this behavior with our developers in our tracking system, with an issue ID of 178023. I have also created a support ticket on your behalf with number CAS-138945-Z9V2K1 in order to link the development issue to it so that you are automatically updated when a Service Release containing your fix is available for download.
Currently you can avoid this issue, by removing the Template setter for the ConditionalFormattingCellControl and use the other setters to implement the formatting.
The development issue with ID of 178023 has been fixed and it is available in the latest Service Release. You can download the Service Release by logging in our web site and then going to Keys and Downloads page.
Thank you for using Infragistics Components.