如何避免WPF中两个用户控件之间的选项卡 [英] How to avoid tab between two usercontrols in WPF

查看:63
本文介绍了如何避免WPF中两个用户控件之间的选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我创建两个控件作为表单。我已通过MDI显示此控件。我打开两个表单,然后我选择form1,单击表单然后选择光标goto form2。我需要限制去表格2。



我尝试过:



KeyboardNavigation.TabNavigation =Cycle



KeyboardNavigation.SetTabNavigation(this,KeyboardNavigationMode.Cycle);





但是没有用到

解决方案

不确定我是否正确理解了这个问题,但是为了防止控件被选中选项卡,您可以为所需的控件或容器设置 KeyboardNavigation.TabNavigation



请考虑以下示例

 <   window     x:class   =  Project1.Window1    xmlns :x   = #unknown >  
xmlns =http ://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x =http://schemas.microsoft.com/winfx/2006/xaml
xmlns:d = http://schemas.microsoft.com/expression/blend/2008
xmlns:mc =http://schemas.openxmlformats.org/markup-compatibility/2006
mc:Ignorable = d
Title =Window1
Height =300
Width =300>
< grid >
< grid.columndefinitions >
< columndefinition / >
< columndefinition / >
< / grid.columndefinitions >
< stackpanel grid.column = 0 keyboardnavigation.tabnavigation = 周期 >
< ; textbox / < span class =code-keyword>>
< textbox / >
< span class =code-keyword>< / stackpanel >
< stackpanel grid.column = 1 keyboardnavigation.tabnavigation = >
< textbox < span class =code-keyword> / >
< textbox / >
< / stackpanel >
< / grid >
< / window >


Hi,

Im creating two controls act as form. i have show this controls through MDI. i opened two forms then i choose form1, click on the form then do tabthe cursor goto form2. i need to restrict to go form2.

What I have tried:

KeyboardNavigation.TabNavigation="Cycle"

KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Cycle);


but no use to achive

解决方案

Not sure if I understand the question correctly, but to prevent a control from being selected by tab you can set KeyboardNavigation.TabNavigation to "None" for desired controls or containers.

Consider the following example

<window x:class="Project1.Window1" xmlns:x="#unknown">
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Title="Window1" 
        Height="300" 
        Width="300">
    <grid>
        <grid.columndefinitions>
            <columndefinition />
            <columndefinition />
        </grid.columndefinitions>
        <stackpanel grid.column="0" keyboardnavigation.tabnavigation="Cycle">
            <textbox />
            <textbox />
        </stackpanel>
        <stackpanel grid.column="1" keyboardnavigation.tabnavigation="None">
            <textbox />
            <textbox />
        </stackpanel>
    </grid>
</window>


这篇关于如何避免WPF中两个用户控件之间的选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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