1

Currently, I have a context menu with submenus containing checkboxes. I have implemented it in a manner similar to below:

<ContextMenu>
    <MenuItem Header="Submenu1">
        <MenuItem Header="item1.1" IsTabStop="False">
            <CheckBox Content="item1.1 checkbox"/>
        </MenuItem>       
        <MenuItem Header="item1.2" IsTabStop="False">
            <CheckBox Content="item1.2 checkbox"/>
        </MenuItem>
        <MenuItem Header="item1.3" IsTabStop="False">
            <CheckBox Content="item1.3 checkbox"/>
        </MenuItem>
    </MenuItem>
    <MenuItem Header="Submenu2">
        <MenuItem Header="item2.1" IsTabStop="False">
            <CheckBox Content="item2.1 checkbox"/>
        </MenuItem>       
        <MenuItem Header="item2.2" IsTabStop="False">
            <CheckBox Content="item2.2 checkbox"/>
        </MenuItem>
        <MenuItem Header="item2.3" IsTabStop="False">
            <CheckBox Content="item2.3 checkbox"/>
        </MenuItem>
    </MenuItem>
</ContextMenu>

I have set the IsTabStop property of each MenuItem to false to fix an earlier bug I found wherein the focus gets stuck on a single menu item (when TAB key is used). However, what happens now is when Submenu1 is open and I try to move focus through the different menu items using the Up or Down arrow key, the submenu closes immediately and highlights the Submenu2 item in the context menu.

I would like to be able to use TAB or arrow keys in moving the focus through the menu items in each submenu. Thank you in advanced for the help.

  • That's how any user would expect these keys to work. I would. The arrow keys change selection, the Tab key changes focus. Avoid breaking user expectations with unusual UI behavior, you'll get him stuck for no good reason. Like not being able to escape the menu trap with anything but the mouse. – Hans Passant Nov 19 '14 at 16:05
  • Do not use `IsTabStop="False"`, but [this](http://stackoverflow.com/a/10218158/1997232). – Sinatr Nov 19 '14 at 16:14

0 Answers0