C# 如何设置Datagrid行标题背景色

C# 如何设置Datagrid行标题背景色,c#,xaml,colors,datagrid,rowheader,C#,Xaml,Colors,Datagrid,Rowheader,我有一个看起来像这样的数据网格 我需要我用紫色突出显示的区域需要设置为背景色(透明),以便它变成黑色。此部分为“行标题”,使用DataGrid LoadingRow=“OnLoadingRow”自动添加计数 但是,我无法设置这个的背景色。我怎么做 谢谢如果您使用WPF,请尝试以下方法: <DataGrid> ... <DataGrid.Resources> <Style TargetType="Button" x

我有一个看起来像这样的数据网格

我需要我用紫色突出显示的区域需要设置为背景色(透明),以便它变成黑色。此部分为“行标题”,使用DataGrid LoadingRow=“OnLoadingRow”自动添加计数

但是,我无法设置这个的背景色。我怎么做


谢谢

如果您使用WPF,请尝试以下方法:

<DataGrid>
    ...
    <DataGrid.Resources>
        <Style TargetType="Button" x:Key="{ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}">
            <Setter Property="Background" Value="Transparent" />
        </Style>
    </DataGrid.Resources>
    ...
</DataGrid>

...
...

谢谢!,这在某种程度上是可行的,但并不完美,但我认为我可以调整代码使其正常工作。非常感谢。
<DataGrid>
    ...
    <DataGrid.Resources>
        <Style TargetType="Button" x:Key="{ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}">
            <Setter Property="Background" Value="Transparent" />
        </Style>
    </DataGrid.Resources>
    ...
</DataGrid>