我有一个看起来像这样的数据网格....
我需要将紫色突出显示的区域设置为背景颜色(透明),使其变为黑色。这部分是“行标题”,使用 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);
}
但是,我无法设置它的背景颜色。我该怎么做?
谢谢
答案 0 :(得分: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>