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

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

问题描述

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

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

如何设置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..

或...

禁用选择行,如果这更容易的话......但是从浏览这个看起来也很hacky的论坛

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

在 WPF DataGrid 中禁用选择

推荐答案

想出了 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天全站免登陆