I have DataGridone that uses AlternatingRowBackgroundto make it more readable. At the same grid I also have a changing background colors for rows based on "IsMouseOver" Setter Propertyin my file App.xaml. The problem I am facing is that lines that have alternating color (they are not white) do not change color "IsMouseOver"when the mouse hangs over it. Basically, color AlternatingRowBackgroundtakes precedence over mine RowStyle. How to make colored lines change when the mouse hangs over them?
App.xaml:
<Style x:Key="RowStyleWithAlternation" TargetType="DataGridRow">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Background" Value="GhostWhite"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="ContextMenu" Value="{x:Null}"/>
<Style.Triggers>
<Trigger Property="AlternationIndex" Value="1">
<Setter Property="Background" Value="#FFD0D0E0"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Purple"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#F9F99F" />
</Trigger>
</Style.Triggers>
</Style>
Xaml user control:
<DataGrid ... AlternatingRowBackground="Gray" RowStyle="{StaticResource RowStyleWithAlternation}" ... />
source
share