Skip to content

Commit

Permalink
DataGrid: add support for RowBackground and AlternatingRowBackground (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
chucker authored and pomianowski committed Feb 17, 2025
1 parent 38e888a commit b6bc9a8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Wpf.Ui/Controls/DataGrid/DataGrid.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
Padding="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="0"
SnapsToDevicePixels="True">
Expand Down Expand Up @@ -157,7 +156,6 @@
<Style x:Key="DefaultDataGridRowStyle" TargetType="{x:Type DataGridRow}">
<Setter Property="Margin" Value="0,2" />
<Setter Property="Padding" Value="4" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="SnapsToDevicePixels" Value="True" />
Expand All @@ -182,7 +180,6 @@
<ControlTemplate TargetType="{x:Type DataGridRow}">
<Border
x:Name="DGR_Border"
Background="Transparent"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{DynamicResource ControlCornerRadius}"
Expand Down Expand Up @@ -376,7 +373,14 @@
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Border>

<ControlTemplate.Triggers>
<Trigger Property="AlternationIndex" Value="0">
<Setter TargetName="DGR_Border" Property="Background" Value="{Binding RowBackground, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
</Trigger>
<Trigger Property="AlternationIndex" Value="1">
<Setter TargetName="DGR_Border" Property="Background" Value="{Binding AlternatingRowBackground, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="True" />
Expand Down

0 comments on commit b6bc9a8

Please sign in to comment.