Skip to content

Commit bb08590

Browse files
Move background color change into ControlTemplate trigger collection
Moving the background changes inside of the ControlTemplate trigger collection changes the binding precedence order such that our "IsMouseOver" trigger is even closer to the DGR_Border than a local value set directly on the DataGrid (i.e. AlternatingRBackground) and thus takes precedence.
1 parent 712fbef commit bb08590

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.xaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"
44
xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf">
@@ -431,6 +431,14 @@
431431
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}, FallbackValue=Visible}" />
432432
</SelectiveScrollingGrid>
433433
</Border>
434+
<ControlTemplate.Triggers>
435+
<Trigger Property="IsMouseOver" Value="True">
436+
<Setter TargetName="DGR_Border" Property="Background" Value="{DynamicResource MaterialDesign.Brush.DataGrid.RowHoverBackground}" />
437+
</Trigger>
438+
<Trigger Property="IsSelected" Value="True">
439+
<Setter TargetName="DGR_Border" Property="Background" Value="{DynamicResource MaterialDesign.Brush.DataGrid.Selected}" />
440+
</Trigger>
441+
</ControlTemplate.Triggers>
434442
</ControlTemplate>
435443
</Setter.Value>
436444
</Setter>
@@ -446,12 +454,6 @@
446454
</Setter.Value>
447455
</Setter>
448456
<Style.Triggers>
449-
<Trigger Property="IsSelected" Value="True">
450-
<Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.DataGrid.Selected}" />
451-
</Trigger>
452-
<Trigger Property="IsMouseOver" Value="True">
453-
<Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.DataGrid.RowHoverBackground}" />
454-
</Trigger>
455457
<Trigger Property="IsNewItem" Value="True">
456458
<Setter Property="Margin" Value="{Binding NewItemMargin, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}, FallbackValue=0}" />
457459
</Trigger>

0 commit comments

Comments
 (0)