Skip to content

Commit ef9e0c9

Browse files
authored
DataGrid: add support for RowBackground and AlternatingRowBackground (#1350)
1 parent 2636287 commit ef9e0c9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Wpf.Ui/Controls/DataGrid/DataGrid.xaml

+7-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
Padding="{TemplateBinding Padding}"
122122
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
123123
VerticalAlignment="{TemplateBinding VerticalAlignment}"
124-
Background="Transparent"
125124
BorderBrush="Transparent"
126125
BorderThickness="0"
127126
SnapsToDevicePixels="True">
@@ -157,7 +156,6 @@
157156
<Style x:Key="DefaultDataGridRowStyle" TargetType="{x:Type DataGridRow}">
158157
<Setter Property="Margin" Value="0,2" />
159158
<Setter Property="Padding" Value="4" />
160-
<Setter Property="Background" Value="Transparent" />
161159
<Setter Property="BorderBrush" Value="Transparent" />
162160
<Setter Property="IsTabStop" Value="False" />
163161
<Setter Property="SnapsToDevicePixels" Value="True" />
@@ -182,7 +180,6 @@
182180
<ControlTemplate TargetType="{x:Type DataGridRow}">
183181
<Border
184182
x:Name="DGR_Border"
185-
Background="Transparent"
186183
BorderBrush="{TemplateBinding BorderBrush}"
187184
BorderThickness="{TemplateBinding BorderThickness}"
188185
CornerRadius="{DynamicResource ControlCornerRadius}"
@@ -376,7 +373,14 @@
376373
</VisualStateGroup>
377374
</VisualStateManager.VisualStateGroups>
378375
</Border>
376+
379377
<ControlTemplate.Triggers>
378+
<Trigger Property="AlternationIndex" Value="0">
379+
<Setter TargetName="DGR_Border" Property="Background" Value="{Binding RowBackground, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
380+
</Trigger>
381+
<Trigger Property="AlternationIndex" Value="1">
382+
<Setter TargetName="DGR_Border" Property="Background" Value="{Binding AlternatingRowBackground, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
383+
</Trigger>
380384
<MultiTrigger>
381385
<MultiTrigger.Conditions>
382386
<Condition Property="IsEnabled" Value="True" />

0 commit comments

Comments
 (0)