如何选择一行(例如数据网格中的第一行)并将其背景颜色设置为例如 C# 中的红色?
我的程序中有以下代码:
gameDataGrid.RowBackground = new SolidColorBrush(Colors.Red);
输出的背景不是红色。
如何选择一行(例如数据网格中的第一行)并将其背景颜色设置为例如 C# 中的红色?
我的程序中有以下代码:
gameDataGrid.RowBackground = new SolidColorBrush(Colors.Red);
输出的背景不是红色。
如果您想根据某个属性更改多行,请连接 LoadingRow 事件并在事件处理程序中更改 DataGridRow 的样式。
在xml中
<DataGrid
AlternatingRowBackground="AliceBlue"
CanUserAddRows="false"
CanUserSortColumns="False"
Grid.Row="2"
Foreground="#FF040404"
Background="#cce6ff"
VirtualizingStackPanel.VirtualizationMode = "recycling"
VirtualizingStackPanel.IsVirtualizing = "true"
EnableColumnVirtualization = "true"
EnableRowVirtualization = "true"
x:Name="dvSalesEntryDataGrid"
AlternationCount="2"
AutoGenerateColumns="False">
</DataGrid>