I'm trying to set different color for odd rows using XAML.
The datagrid in question has 3 different types of data, which I want to color differently, and simply changing AlternatingRowBackground won't do.
I'm planning on using something like
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Type}" Value="0"/>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="False"/>
<Condition Binding="{Binding IsOddRow, RelativeSource={RelativeSource Self}}" Value="False"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="#FFDFE6ED"/>
</MultiDataTrigger>
There doesn't seem to be such a property as IsOddRow
. What property should I check instead?
Almost every answer use
AlternationCount="2"
but I find it a little bit too limiting. On my side I use something likeAlternationCount="{ Binding MainData.ProjColl.Count}"
in order to number my rows until the end ( take care it starts at 0 ! ).In this case I need a value Converter as mentioned by @Danny Varod.
I use the converter to alternate the color of the rows ( nearly answering the question )
And the calling XAML
and some discrete screenshots
Another part of the same code: Simple way to display row numbers on WPF DataGrid