我可以使WPF DataGridRow不可选择吗? [英] Can I make a WPF DataGridRow unselectable?

查看:1149
本文介绍了我可以使WPF DataGridRow不可选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在datagrid上有一种样式可以基于属性绑定禁用DataGridRow.这使该行无法选择,这就是我想要的.但是,我仍然可以使用至少2种其他方式来选择禁用的行.第一个是我是否在围绕禁用行的两个启用行之间使用拖动动作.第二个是如果我单击数据网格左上方的全选"按钮.有没有办法使特定的行完全不可选择?

这是我目前拥有的:

I have a style on my datagrid to disable a DataGridRow based on a property binding. This makes the row unselectable, which is what I want. However, I am still able to select the disabled rows using at least 2 other ways. The first is if I use a dragging motion between two enabled rows that surround the disabled row. The second is if I click on the "select all" button on the top left of the datagrid. Is there a way to make specific rows completely unselectable?

This is what I currently have:

<datagrid.rowstyle>
    <Style TargetType="{x:Type DataGridRow}">
        <Style.Triggers>
            <datatrigger binding="{Binding DisableMe}" value="True">
                <setter property="IsEnabled" value="False" />
            </datatrigger>
        </Style.Triggers>
    </Style>
</datagrid.rowstyle>

推荐答案

我不认为您可以使用样式来做到这一点.
但是您可以使用SelectionChanged事件撤消选择.
I don''t think you can do that with a style.
But you could use the SelectionChanged event to undo the selection.


这篇关于我可以使WPF DataGridRow不可选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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