DataGrid选项卡导航跳过列 [英] DataGrid tab navigation skip column

查看:189
本文介绍了DataGrid选项卡导航跳过列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WPF中有一个带有模板列的datagrid。网格中的几列是唯一的,其他焦点成为可编辑(而不是标签,文本框,复选框等)。



我想要实现的是任何人都知道如何实现这一点?





谢谢!
Vladan






不,不工作:(



这是完整的单元格...尝试用KeyboardNavigation.IsTabStop和IsTabStop单独...没有工作

  < DataGridTemplateColumn Header ={x:Static local:MainWindowResources.gasNameLabel}Width =*MinWidth =150IsReadOnly =True> 
< DataGridTemplateColumn.CellTemplate>
& DataTemplate>
< ContentControl Content ={Binding Path = Name}ContentTemplate ={StaticResource DataGridTextBoxView}/>
< / DataTemplate>
< /DataGridTemplateColumn.CellTemplate>
< DataGridTemplateColumn.CellStyle>
< Style TargetType ={x:Type DataGridCell}>
< Style.Triggers>
< Trigger Property =IsReadOnly Value =true>
< Setter Property =KeyboardNavigation.IsTabStopValue =False/>
< /触发>
< /Style.Triggers>
< / Style>
< /DataGridTemplateColumn.CellStyle>
< / DataGridTemplateColumn>


解决方案

这样的东西可以工作:

 < DataGrid.Resources> 
< Style TargetType =DataGridCell>
< Style.Triggers>
< Trigger Property =IsReadOnlyValue =True>
< Setter Property =IsTabStopValue =False/>
< / Trigger>
< /Style.Triggers>
< / Style>
< /DataGrid.Resources>


I have a datagrid with template columns in WPF. Couple of columns in the grid are readonly, others on focus become editable (instead of labels, textboxes, checkboxes and such appear).

What I would like to achieve is that the readonly columns are skipped when I am tabbing through the grid's columns.

Anyone know how to achieve this?

Thanks! Vladan


Nope, not working :(

Here is the complete cell...tried it with KeyboardNavigation.IsTabStop and IsTabStop alone...didn't work

<DataGridTemplateColumn Header="{x:Static local:MainWindowResources.gasNameLabel}" Width="*" MinWidth="150" IsReadOnly="True">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <ContentControl Content="{Binding Path=Name}" ContentTemplate="{StaticResource DataGridTextBoxView}" />
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
    <DataGridTemplateColumn.CellStyle>
        <Style TargetType="{x:Type DataGridCell}">
            <Style.Triggers>
                <Trigger Property="IsReadOnly" Value="true">
                    <Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </DataGridTemplateColumn.CellStyle>
</DataGridTemplateColumn>

解决方案

Something like this would work:

<DataGrid.Resources>
    <Style TargetType="DataGridCell">
        <Style.Triggers>
            <Trigger Property="IsReadOnly" Value="True">
                <Setter Property="IsTabStop" Value="False"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</DataGrid.Resources>

这篇关于DataGrid选项卡导航跳过列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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