Exemplo n.º 1
0
        /// <summary>
        /// Ensures the nav menu reflects reality when navigation is triggered outside of
        /// the nav menu buttons.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnNavigatingToPage(object sender, NavigatingCancelEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.Back)
            {
                var item = (from p in this.navlist where p.DestPage == e.SourcePageType select p).SingleOrDefault();
                if (item == null && this.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 this.AppFrame.BackStack.Reverse())
                    {
                        item = (from p in this.navlist where p.DestPage == entry.SourcePageType select p).SingleOrDefault();
                        if (item != null)
                        {
                            break;
                        }
                    }
                }

                var container = (ListViewItem)NavMenuList.ContainerFromItem(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);
                if (container != null)
                {
                    container.IsTabStop = true;
                }
            }
        }
        private void OnNavigatingToPage(object sender, NavigatingCancelEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.Back)
            {
                var item = (from p in this.navlist where p.DestPage == e.SourcePageType select p).SingleOrDefault();
                if (item == null && this.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 this.AppFrame.BackStack.Reverse())
                    {
                        item = (from p in this.navlist where p.DestPage == entry.SourcePageType select p).SingleOrDefault();
                        if (item != null)
                        {
                            break;
                        }
                    }
                }

                var container = (ListViewItem)NavMenuList.ContainerFromItem(item);
                if (container != null)
                {
                    container.IsTabStop = false;
                }
                NavMenuList.SetSelectedItem(container);
                if (container != null)
                {
                    container.IsTabStop = true;
                }
            }
        }
Exemplo n.º 3
0
        private void OnNavigatingToPage(object sender, NavigatingCancelEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.Back)
            {
                var item = (from p in this.navlist where p.DestPage == e.SourcePageType select p).SingleOrDefault();
                if (item == null && this.AppFrame.BackStackDepth > 0)
                {
                    foreach (var entry in this.AppFrame.BackStack.Reverse())
                    {
                        item = (from p in this.navlist where p.DestPage == entry.SourcePageType select p).SingleOrDefault();
                        if (item != null)
                        {
                            break;
                        }
                    }
                }

                var container = (ListViewItem)NavMenuList.ContainerFromItem(item);

                if (container != null)
                {
                    container.IsTabStop = false;
                }
                NavMenuList.SetSelectedItem(container);
                if (container != null)
                {
                    container.IsTabStop = true;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Enable or disable the selected items from the navigation ListView
        /// </summary>
        /// <param name="collection">Collection of items to update</param>
        /// <param name="enable">Enable or disable</param>
        private void EnableNavMenuItem(IEnumerable <NavMenuItem> collection, bool enable)
        {
            foreach (NavMenuItem it in collection)
            {
                ListViewItem container = (ListViewItem)NavMenuList.ContainerFromItem(it);

                if (container != null)
                {
                    container.IsEnabled = enable;
                }
            }
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Ensures the nav menu reflects reality when navigation is triggered outside of
        /// the nav menu buttons.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnNavigatingToPage(object sender, NavigatingCancelEventArgs e)
        {
            _appVersion.Text = string.Format("Version: {0}.{1}.{2}.{3}",
                                             Windows.ApplicationModel.Package.Current.Id.Version.Major,
                                             Windows.ApplicationModel.Package.Current.Id.Version.Minor,
                                             Windows.ApplicationModel.Package.Current.Id.Version.Build,
                                             Windows.ApplicationModel.Package.Current.Id.Version.Revision);
            if (e.NavigationMode == NavigationMode.New)
            {
                //Updates nav menu if invoked from back/next buttons.
                {
                    List <NavMenuItem> newList = new List <NavMenuItem>
                    {
                        navlist[0],
                        navlist2[0],
                        //navlist2[1],
                        //navlist2[2],
                        //navlist2[3],
                        navlist3[0]
                    };

                    var item = (from p in (newList) where p.DestPage == e.SourcePageType select p).SingleOrDefault();

                    //Set blue tab indicator for selected page
                    //foreach (var i in this.navlist)
                    //{
                    //    i.IsSelected = false;
                    //}
                    //foreach (var i in this.navlist2)
                    //{
                    //    i.IsSelected = false;
                    //}
                    //foreach (var i in this.navlist3)
                    //{
                    //    i.IsSelected = false;
                    //}
                    if (item != null)
                    {
                        item.IsSelected = true;
                    }

                    //Set the selected container.
                    var container = (ListViewItem)NavMenuList.ContainerFromItem(item);
                    Debug.WriteLine("" + container);
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Ensures the nav menu reflects reality when navigation is triggered outside of
        /// the nav menu buttons.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnNavigatingToPage(object sender, NavigatingCancelEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New)
            {
                //Updates nav menu if invoked from back/next buttons.
                {
                    List <NavMenuItem> newList = new List <NavMenuItem>();
                    newList.Add(navlist[0]);
                    newList.Add(navlist[1]);
                    newList.Add(navlist[2]);
                    newList.Add(navlist2[0]);
                    newList.Add(navlist2[1]);
                    newList.Add(navlist2[2]);
                    newList.Add(navlist2[3]);
                    newList.Add(navlist3[0]);

                    var item = (from p in (newList) where p.DestPage == e.SourcePageType select p).SingleOrDefault();

                    //Set blue tab indicator for selected page
                    foreach (var i in this.navlist)
                    {
                        i.IsSelected = false;
                    }
                    foreach (var i in this.navlist2)
                    {
                        i.IsSelected = false;
                    }
                    foreach (var i in this.navlist3)
                    {
                        i.IsSelected = false;
                    }
                    if (item != null)
                    {
                        item.IsSelected = true;
                    }

                    //Set the selected container.
                    var container = (ListViewItem)NavMenuList.ContainerFromItem(item);
                    Debug.WriteLine("" + container);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Ensures the nav menu reflects reality when navigation is triggered outside of
        /// the nav menu buttons.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnNavigatingToPage(object sender, NavigatingCancelEventArgs e)
        {
            //if (e.NavigationMode == NavigationMode.Back)
            if (e.SourcePageType == typeof(ViewerPage))
            {
                return;
            }
            var item = (from p in this.navlist where p.DestPage == e.SourcePageType select p).SingleOrDefault();

            //if (item == null && this.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 this.AppFrame.BackStack.Reverse())
            //    {
            //        item = (from p in this.navlist where p.DestPage == entry.SourcePageType select p).SingleOrDefault();
            //        if (item != null)
            //            break;
            //    }
            //}
            HighlightNavigationBtn((ListViewItem)NavMenuList.ContainerFromItem(item));
        }