【问题标题】:How to set Datagrid row header background color如何设置 Datagrid 行标题背景颜色
【发布时间】:2021-05-02 04:40:39
【问题描述】:

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

我需要将我以紫色突出显示的区域设置为背景颜色(透明),使其变为黑色。这部分是“行标题”,使用 DataGrid LoadingRow="OnLoadingRow"

自动添加计数
    private void OnLoadingRow(object sender, DataGridRowEventArgs e)
    {
        e.Row.Header = (e.Row.GetIndex()+1).ToString();

        tickerListView.Items.MoveCurrentToLast();
        tickerListView.ScrollIntoView(tickerListView.Items.CurrentItem);
    }

但是,我无法设置它的背景颜色。我该怎么做?

谢谢

【问题讨论】:

    标签: c# xaml colors datagrid rowheader


    【解决方案1】:

    如果您使用 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>
    

    【讨论】:

    • 谢谢!,这有点工作,不完美,但我想我可以调整代码使其工作。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-31
    • 2013-02-06
    相关资源
    最近更新 更多