2

I have a view with a menu:

<Menu IsTabStop="False">
    <MenuItem
        Header="_File"
        IsTabStop="True">
        <MenuItem
            Header="New / Start Over"
            IsTabStop="True"
            InputGestureText="Ctrl+N"
            Command="{x:Static common:Commands.StartOverCommand}" />
        <Separator
            IsTabStop="False" />
        <MenuItem
            Header="Log Out"
            IsTabStop="True"
            InputGestureText="F12"
            Click="LogoutMenuItem_Click" />
        <MenuItem
            Header="E_xit"
            IsTabStop="True"
            InputGestureText="Alt+F4"
            Click="ExitMenuItem_Click" />
    </MenuItem>
    <MenuItem
        Header="_Edit"
        IsTabStop="True">
        <MenuItem
            Header="Undo Edit Field"
            IsTabStop="True"
            InputGestureText="Ctrl+Z"
            Click="_undoMenuItem_Click" />
        <MenuItem
            Header="Redo Edit Field"
            IsTabStop="True"
            InputGestureText="Ctrl+Y"
            Click="_redoMenuItem_Click" />
    </MenuItem>
    <MenuItem
        Header="_Tools"
        IsTabStop="True">
        <MenuItem
            Header="Comments"
            IsTabStop="True"
            InputGestureText="Ctrl+M"
            Click="_commentsMenuItem_Click" />
    </MenuItem>
</Menu>

I would like to be able to navigate through the menus (File, Edit, Tools) by using the right and left arrow keys, which I was able to accomplish by making these MenuItems IsTabStop="True". But since I did this I am able to tab to the menu as I cycle through the other valid fields on a page. When I use Alt+F to put focus on the File menu I want to be able to cycle through the 3 menus with the arrow keys, but I don't want to be able to tab to these menus from the page. How would I accomplish this?

Kevin R
  • 934
  • 1
  • 9
  • 23
  • 3
    Try [KeyboardNavigation.TabNavigation Attached Property](http://msdn.microsoft.com/en-us/library/system.windows.input.keyboardnavigation.tabnavigation.aspx) with [KeyboardNavigationMode.None](http://msdn.microsoft.com/en-us/library/system.windows.input.keyboardnavigationmode.aspx) on Menu – LPL Apr 18 '12 at 20:45
  • @LPL You should add that as an answer. It is far better than mine. – kevev22 Apr 18 '12 at 20:59

1 Answers1

3

Use the KeyboardNavigation.TabNavigation Attached Property with KeyboardNavigationMode.None on menu.

<Menu KeyboardNavigation.TabNavigation="None">
LPL
  • 16,827
  • 6
  • 51
  • 95
  • I had a similar problem where the arrow keys would navigate from parts of my MainWindow to the Menu, which is totally not expected! Landing here introduced me to the KeyboardNavigation attached properties, and I set my Menu's `KeyboardNavigation.DirectionNavigation="None"` which fixed it. Thanks much LPL for your answer here which was the critical step in solving my problem as well – aggieNick02 Apr 15 '13 at 18:16