Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Toolbar does not pass focus to the next control on tab-key

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>
like image 719
Pete Avatar asked Mar 16 '11 10:03

Pete


1 Answers

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.

like image 164
Gimno Avatar answered Oct 31 '22 06:10

Gimno