In using WPF tab controls, is there a way to assign a keyboard shortcut to move between tabs in the control?
Or, is it possible to assign the
tabIndex in such a way that when the user reaches the last field in the first tab and hits keyboard tab key again, that the first control in the next tab gains focus?
There already is a keyboard shortcut: Ctrl+Tab (Ctrl+Shift+Tab for reverse)
If you want to add additional shortcuts you can add a
KeyBinding to the
TabControl.InputBindings, you may need to create the command which does the switching yourself though.
For future readers, I found HowTo add an ALT+ shortcut key to a TabItem in WPF? helpful (if you want to assign an
Alt+<key> hotkey for each tab):
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>