如何使用隐藏代码删除 wpf 数据网格中选定行(或单元格)的突出显示
How to remove highlight of a selected row (or cell) in a wpf datagrid using code behind
我发现这段代码在 wpf xaml 中运行完美。
如何在代码隐藏中执行此操作?
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF0000"/>
</DataGrid.Resources>
您可以从后面的代码中添加这样的资源 -
dataGrid.Resources.Add(SystemColors.HighlightBrushKey, "#FF0000");
您需要获取网格对象,然后在该网格的资源中添加新资源
我发现这段代码在 wpf xaml 中运行完美。 如何在代码隐藏中执行此操作?
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF0000"/>
</DataGrid.Resources>
您可以从后面的代码中添加这样的资源 -
dataGrid.Resources.Add(SystemColors.HighlightBrushKey, "#FF0000");
您需要获取网格对象,然后在该网格的资源中添加新资源