防止单元格级别的制表位,但仍允许行在 WPF DataGrid 中具有制表位 [英] Prevent cell level tab stops, but still allow rows to have tabstops in a WPF DataGrid

查看:26
本文介绍了防止单元格级别的制表位,但仍允许行在 WPF DataGrid 中具有制表位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望阻止单个单元格上的制表位,但允许行级制表位

I wish to prevent tabstops on individual cells, but allow row level tabstops

我以为我可以使用 CellStyle 在所有单元格上禁用 IsTabStop

I thought I could just use CellStyle to disable IsTabStop on all cells

<DataGrid.CellStyle>
    <Style TargetType="DataGridCell">
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="IsTabStop" Value="false"/>
    </Style>
</DataGrid.CellStyle>

但这会阻止行也有制表位

But this prevents rows from having tabstops too

所以我想我应该使用 RowStyle 在行上启用制表位

So I thought I should enable tabstops on rows using RowStyle

<DataGrid.RowStyle>
    <Style TargetType="DataGridRow">
        <Setter Property="IsTabStop" Value="true"/>
    </Style>
</DataGrid.RowStyle>

但这也不起作用

有人有什么想法吗?

推荐答案

我的解决方案是这样 -

My solution was this -

将所有 DataGridCell 列的 IsTabStop 更改为 false

Change IsTabStop to false for all DataGridCell columns

将我的主列(即 DataGridTemplateColumn)的 IsTabStop 更改为 true

Change IsTabStop to true for my main column which is a DataGridTemplateColumn

<DataGrid.CellStyle>
    <Style TargetType="DataGridCell">
        <Setter Property="IsTabStop" Value="false"/>
    </Style>
</DataGrid.CellStyle>


<DataGrid.Columns>

    <DataGridTemplateColumn Header="File name" Width="435">

        <DataGridTemplateColumn.CellStyle>
            <Style TargetType="DataGridCell">
                <Setter Property="IsTabStop" Value="true"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            </Style>
        </DataGridTemplateColumn.CellStyle>

    ...........

通过包含这一行,我可以禁用虚线方形边框

By including this line I am able to disable the dotted line square border

<Setter Property="FocusVisualStyle" Value="{x:Null}"/>

编辑*

没关系,这太麻烦了.我认为此时使用列表视图对我来说更有意义.

Nevermind, this is too much trouble. I think it makes more sense for me to use a listview at this point.

这篇关于防止单元格级别的制表位,但仍允许行在 WPF DataGrid 中具有制表位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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