我看到了很多关于如何在DataGrid中设置所选行样式的示例,比如下面这样:
How can I set the color of a selected row in DataGrid
我可以禁用选定的行样式吗?我不想重写选定行更改的每一项内容。只是不想要任何明显的改变。比创建模板更简单的方法。
或者..。
禁用选择行,如果这样更容易的话..但从浏览这个论坛来看,这似乎也很令人生厌
发布于 2010-06-19 04:42:43
解决了XAML中摆脱选择样式的问题。不是很理想,但足够接近..
<Style x:Key="CellStyle" TargetType="{x:Type DataGridCell}">
<Setter Property="Foreground" Value="Black" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="BorderBrush" Value="{x:Null}" />
</Trigger>
</Style.Triggers>
</Style>发布于 2015-04-10 18:44:38
以下是对我有效的方法:
<DataGrid>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<Trigger Property="DataGridCell.IsSelected" Value="True">
<Setter Property="BorderBrush">
<Setter.Value>
<SolidColorBrush Color="Transparent"/>
</Setter.Value>
</Setter>
<Setter Property="Foreground"
Value="{DynamicResource
{x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="Transparent"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<!-- ... -->
</DataGrid>发布于 2010-08-14 04:13:37
我找到了另一种适合我的情况的方法。我为所有单元格设置此样式,因为我不希望用户选择任何单元格。
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="IsHitTestVisible" Value="False"/>
</Style>https://stackoverflow.com/questions/3046988
复制相似问题