Keyboard navigation in typical WPF Business Line Application
- by Guge
I have a WPF business line application with a tabbed userinterface, menus and toolbars. The application must be navigable through a keyboard, some users like to minimize mouse use.
I have thrown together the included XAML sample to illustrate the problem of keyboard navigation. Using the tab key I can only get to the menu, and then to the toolbar. I have tried various attached properties for KeyboardNavigation and FocusManager, but I have not succeeded in the following goals:
Navigate to the contents of the first tabpage using the keyboard.
Disable tab key navigation from tabpage to menu and toolbar.
Change tabpage using Ctrl-Tab.
<Window x:Class="WpfApplication4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="408" Width="569"
>
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="_File">
<MenuItem Header="Open"/>
</MenuItem>
<MenuItem Header="_Edit"></MenuItem>
</Menu>
<ToolBarTray DockPanel.Dock="Top">
<ToolBar>
<Label Target="{Binding ElementName=SearchBox}">
_Search
</Label>
<TextBox Name="SearchBox" Width="80"></TextBox>
<Button>Search</Button>
</ToolBar>
</ToolBarTray>
<StatusBar DockPanel.Dock="Bottom">
Statusbar here
</StatusBar>
<TabControl>
<TabItem Header="File 1">
<WrapPanel>
<Button>Click</Button>
<CheckBox>Check</CheckBox>
<Slider Minimum="0" Maximum="100" Width="150"/>
</WrapPanel>
</TabItem>
<TabItem Header="File 2">
</TabItem>
<TabItem Header="File 3">
</TabItem>
</TabControl>
</DockPanel>