我想在xaml中设置DataGrid
的背景颜色。我创建了以下样式:
<Style x:Key="StandardSpaltenKopf" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="#303433" />
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Height" Value="20"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0"/>
</Style>
我设置的背景色仅在文本后面,而列标题的其余部分以另一种颜色显示(请参见图片中的April和Mai)。如何填充其余的列标题?
更新1:
以下内容也不起作用:
<Style x:Key="StandardSpaltenKopf" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Height" Value="28"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="BorderBrush" Value="{StaticResource Dunkelgrau}" />
<Setter Property="Padding" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
<Grid Background="{StaticResource Dunkelgrau}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<ContentPresenter></ContentPresenter>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>