Ejemplo n.º 1
0
        /// <summary>
        /// Gets the container from the given navigation item, either from the main list or the bottom dock.
        /// </summary>
        /// <remarks>
        /// UpdateLayout is invoked to make sure the containers are available even when the ListView was not rendered.
        /// </remarks>
        /// <param name="item">The navigation menu item.</param>
        /// <returns>The list view item container.</returns>
        private ListViewItem GetContainerFromItem(NavMenuItem item)
        {
            NavMenuList.UpdateLayout();
            NavMenuList.ScrollIntoView(item);
            var container = (ListViewItem)NavMenuList.ContainerFromItem(item);

            if (container == null)
            {
                NavMenuListBottomDock.UpdateLayout();
                container = (ListViewItem)NavMenuListBottomDock.ContainerFromItem(item);
            }

            return(container);
        }
Ejemplo n.º 2
0
        private NavMenuItem SelectNavigationItem(NavMenuItem item)
        {
            if (item == null && AppFrame.BackStackDepth > 0)
            {
                // in cases where a page drills into sub-pages then we'll highlight the most recent
                // navigation menu item that appears in the BackStack
                foreach (var entry in AppFrame.BackStack.Reverse())
                {
                    item = GetNavigationItem(entry.SourcePageType);
                    if (item != null)
                    {
                        break;
                    }
                }
            }
            else if (item == null)
            {
                var page = AppFrame.Content as UniversalPage;
                if (page != null)
                {
                    item = GetNavigationItem(page.ParentPage);
                }
            }

            var container = GetContainerFromItem(item);

            // while updating the selection state of the item prevent it from taking keyboard focus.  If a
            // user is invoking the back button via the keyboard causing the selected nav menu item to change
            // then focus will remain on the back button.
            if (container != null)
            {
                container.IsTabStop = false;
            }

            NavMenuList.SetSelectedItem(container);
            NavMenuListBottomDock.SetSelectedItem(container);

            if (container != null)
            {
                container.IsTabStop = true;
            }
            return(item);
        }