13
votes

I have created a simple WPF application with a TextBox and a Toolbar containing two buttons.

When I click the textbox and press the tab-key, input focus is moved to the first toolbar button. Pressing tab again moves input to the next tab button. So far, so good. But pressing tab again moves input focus to the first toolbar button, where it should have been moved to the text box.

So once the toolbar receives input focus, it stays there, and you cannot move focus out except using the mouse.

Why? And how can I remedy that?

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="WpfApplication1.MainWindow"
    x:Name="Window"
    Title="MainWindow"
    Width="640" Height="480">

    <StackPanel x:Name="LayoutRoot">
        <ToolBar VerticalAlignment="Top">
            <Button Content="Test1" />
            <Button Content="Test2" />
        </ToolBar>
        <TextBox />
    </StackPanel>
</Window>
1

1 Answers

20
votes

The solution is quite simple, you just have to add KeyboardNavigation.TabNavigation="Continue" to your ToolBar. Then the focus gets passed back to the TextBox again.