Can I use a Conditional format rule to change the background of a whole row in a grid?
(For example, I have a 'grade' column in my grid. If the grade value is less than 60, I want the background color of the whole row to be red).
If not, is there some other way to achieve this?
Hello Hagit,
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
Sorry for my delayed reply.
I still couldn't achieve what I wanted.
I need to change the background of rows in the grid (XamGrid / XamDataGrid) according to a property of type enum that is displayed in the grid as an image.
I took the sample you have attached in your last reply, and added the following:
In MainWindow.xaml.cs
In MainWindow.xaml
<ig:TemplateColumn Key="Validity">
<ig:TemplateColumn.ItemTemplate>
<DataTemplate>
<Image Width="16" Height="16" Source="{Binding Path=Validity, Converter={StaticResource validityToImageConverter} }" />
</DataTemplate>
</ig:TemplateColumn.ItemTemplate>
…
</ig:TemplateColumn>
Now, I want to set yellow background of rows that have the Validity property set to Warning. How do I do this?
I have modified the sample further, so now it has the functionality you want. Basically I changed the way you set the Value of the Validity Column's EqualToConditionalFormatRule, because it is an Enum type. I also added a Style fort he CellValuePreseter in the XamDataGrid, so now the XamDataGrid shows the images, too. Another modification I make is moving the definition of the Enum Type outside of the ChartData class. Please let me know if this helps you or you have further questions on this matter. Looking forward for your reply.
I didn't really understand why the enum type had to be taken out of the CharData class. (This is only an example, but in my real application all the enum types belong to classes). But other than that, I got it.
Thanks a lot.
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well. Also if you define the enum inside a class the value of the EqualToConditionalFormatRule should look like this:
Value="{x:Static local:ChartData+EValidity.Warning}"
Thanks again.