Exemple #1
0
        internal override bool FocusItem(ItemInfo info, ItemNavigateArgs itemNavigateArgs)
        {
            bool returnValue = base.FocusItem(info, itemNavigateArgs);

            // Trying to navigate from the current menuitem (this) to an adjacent menuitem.

            if (itemNavigateArgs.DeviceUsed is KeyboardDevice)
            {
                // If the item is a TopLevelHeader then when you navigate onto it, the submenu will open
                // and we should select the first item in the submenu.  The parent MenuItem will take care
                // of opening the submenu but doesn't know whether focus changed because of a mouse action
                // or a keyboard action.  Help out by focusing the first thing in the new submenu.

                // Assume that KeyboardNavigation.Current.Navigate moved focus onto the element onto which
                // it navigated.
                MenuItem newSelection = info.Container as MenuItem;
                if (newSelection != null &&
                    newSelection.Role == MenuItemRole.TopLevelHeader &&
                    newSelection.IsSubmenuOpen)
                {
                    newSelection.NavigateToStart(itemNavigateArgs);
                }
            }
            return(returnValue);
        }
Exemple #2
0
        // Token: 0x060051CD RID: 20941 RVA: 0x0016E190 File Offset: 0x0016C390
        internal override bool FocusItem(ItemsControl.ItemInfo info, ItemsControl.ItemNavigateArgs itemNavigateArgs)
        {
            bool result = base.FocusItem(info, itemNavigateArgs);

            if (itemNavigateArgs.DeviceUsed is KeyboardDevice)
            {
                MenuItem menuItem = info.Container as MenuItem;
                if (menuItem != null && menuItem.Role == MenuItemRole.TopLevelHeader && menuItem.IsSubmenuOpen)
                {
                    menuItem.NavigateToStart(itemNavigateArgs);
                }
            }
            return(result);
        }