wpf:DataGrid禁用选定的行样式-或行选择 [英] wpf: DataGrid disable selected row styles - or row selecting

查看:701
本文介绍了wpf:DataGrid禁用选定的行样式-或行选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了很多有关如何设置DataGrid中选定行样式的示例,例如:

I am seeing a lot of examples on how to style Selected rows in DataGrid such as this one:

How can I set the color of a selected row in DataGrid

我可以禁用所选行样式吗?我不想覆盖所选行更改的每件事。只是不希望有任何明显的变化。

Can i just disabled selected row styling? i don't want to have to override every single thing that selected row changes. Just don't want any visible changes. Gotta be easier way than to create templates..

或..

禁用选择行,如果那样的话,比创建模板更简单。更容易..但通过浏览该论坛似乎也很黑

disable selecting rows, if that is easier.. but from browsing this forum that seems hacky as well

在WPF数据网格中禁用选择

推荐答案

弄清楚了XAML以摆脱选择样式..不理想,但足够接近。.

figured out the XAML to get rid of selection style.. not ideal, but close enough..

<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>

这篇关于wpf:DataGrid禁用选定的行样式-或行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆