0

我正在使用 Xceed 数据网格控件,我正在尝试更改标题颜色,但似乎遇到了一些问题。我现在拥有的是以下代码片段:

Style style = new Style(typeof(ColumnManagerRow));
style.Setters.Add(new Setter(ColumnManagerRow.BackgroundProperty, Brushes.Black));
this.grid.Resources[typeof(ColumnManagerRow)] = style;

这在大多数情况下都有效,但我仍然看到它周围有一些灰色。任何帮助将不胜感激。

编辑

我添加了一个图像,其中包含我希望具有相同颜色的选定区域。 在此处输入图像描述

4

1 回答 1

2

您可以在 XAML 中执行此操作:

<ControlTemplate x:Key="HeaderTemplate" TargetType="{x:Type xcdg:ColumnManagerCell}">
    <TextBlock Text="{TemplateBinding Content}">
        <TextBlock.Style>
            <Style TargetType="{x:Type TextBlock}">
                <Setter Property="Background" Value="Black" />
                <Setter Property="Foreground" Value="Red" />
            </Style>
        </TextBlock.Style>
    </TextBlock>
</ControlTemplate>

<Style TargetType="{x:Type xcdg:ColumnManagerRow}">
    <Setter Property="Background" Value="Black"/>
    <Setter Property="BorderBrush" Value="Black"/>
</Style>                

<Style TargetType="{x:Type xcdg:ColumnManagerCell}">
    <Setter Property="Template" Value="{StaticResource HeaderTemplate}"/>
</Style>
于 2012-12-04T11:24:55.200 回答