在WPF(MVVM,没有代码隐藏),说我有以下xaml:
<StackPanel>
<Button>Normal 1</Button>
<Button>Special</Button> <!--This button should not tab focus, but still focus via arrow keys-->
<Button>Normal 2</Button>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
默认情况下,您可以(1)按钮之间的标签或(2)按钮之间的上/下箭头.我想使按钮之一- 特殊按钮- 不通过标签可成为焦点,但通过上/下依然可获得焦点.我试过了IsTabStop="False"
,但这也阻止了通过方向导航(向上/向下箭头)聚焦该按钮.
如何继续允许方向导航,如何从标签导航中删除单个按钮?对于所有其他控件,选项卡和箭头应该不受影响.
我试过的组合IsTabStop
,KeyboardNavigation.TabNavigation
和KeyboardNavigation.DirectionalNavigation
无济于事.也许我找不到合适的搭配.或许还有另一种方法.想法?
编辑:好的,我正在加入一笔赏金.为了清楚起见,我正在寻找一个MVVM,没有代码隐藏的方式来装饰一个控件(例如通过样式,附加属性,附加行为等),这样就可以从Tab键顺序中删除它,同时保持有效的方向导航目标.对窗口(或类似)中的控件的硬编码知识是不可接受的.这需要是一个通用的,可重用的解决方案.像:<Button AllowDirectionalNavigationButPreventTabNavigation="True"/>
.
我正在尝试让 UserControl 正确地进行选项卡并感到困惑。逻辑树看起来像这样。
|-Window
-Grid
-TabControl
-TabItem
-StackPanel
-MyUserControl
|-StackPanel
-GroupBox
-Grid
-ComboBox
-Textbox1
-Textbox2
Run Code Online (Sandbox Code Playgroud)
Everything works fine, except when the visibility converter for the ComboBox returns Visibility.Collapsed
(don't allow user to change database mode), then when textbox1 is selected, instead of being able to tab through the controls in the UserControl, the focus shifts to a button在窗口底部声明。除了显示的控件之外,没有设置 TabIndex 或 FocusManager 属性。
我的头撞在砖墙上,我一定是遗漏了什么。我试过 IsFocusScope=True/False,用 FocusedElement 玩,如果 ComboBox 是不可见的 ( Visibility.Collapsed
) ,没有任何效果。
<Window x:Class="MyNamespace.Client.WinInstaller"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
FocusManager.FocusedElement="{Binding ElementName=tabWizard}">
<Window.Resources>
<props:Settings …
Run Code Online (Sandbox Code Playgroud) 我想让用户能够浏览页面的链接。
这是大多数浏览器中的默认行为,但是一旦页面包含一个input
元素,它就会成为(取决于浏览器)页面上唯一的可选项卡元素,例如a
无法通过键盘访问元素。tabindex
无论是否设置,这都不会改变。
请参阅以下示例。聚焦输入元素,按tab
几下;Chrome 会聚焦链接,而 Firefox 和 Safari 会跳过这些元素。
<div>
<form>
<input type="text" tabindex="0">
<button tabindex="0">send</button>
</form>
</div>
<a href="#" tabindex="0">Link</a>
<a href="#" tabindex="0">Link</a>
Run Code Online (Sandbox Code Playgroud)
如何在没有 JavaScript 的情况下实现跨浏览器键盘导航并规避此问题?
html accessibility cross-browser keyboard-navigation tabindex
我有一堆带有不同文件名的html文件,我需要添加一个选项来使用键盘箭头键进行导航(上一个和下一个文件).
文件名不是动态的.例如:filename.html,anotherfile.html,thirdone.html等.
所以我需要.js文件中的导航内容,以及我应该链接html文件中的上一个,下一个按钮的内容?