在使用 WPF 选项卡控件时,是否可以分配键盘快捷键以在控件中的选项卡之间移动?
或者,是否可以这样分配 tabIndex
,当用户到达第一个选项卡中的最后一个字段并再次按下键盘 Tab 键时,下一个选项卡中的第一个控件获得焦点?
最佳答案
对于 future 的读者,我找到了 HowTo add an ALT+ shortcut key to a TabItem in WPF? 很有帮助(如果你想为每个选项卡分配一个 Alt+<key>
热键):
The following example should get you far enough to get you started. Basically, you need to create the Header using an Xml Element instead of the Attribute usage, and specify the AccessText, with the letter following the underscore specifying the hotkey to be assigned.
<Window x:Class="WpfApplication8.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<TabControl>
<TabItem>
<TabItem.Header>
<AccessText Text="Tab_One"/>
</TabItem.Header>
</TabItem>
<TabItem>
<TabItem.Header>
<AccessText Text="Tab_Two"/>
</TabItem.Header>
</TabItem>
</TabControl>
</Grid>
</Window>
关于wpf - 选项卡控件上选项卡之间的键盘快捷方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8096675/