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

查看:82
本文介绍了防止单元格级别的制表位停止,但仍允许行在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>

但这也不起作用

有人有想法吗?

推荐答案

我的解决方法是这个-

将所有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天全站免登陆