예제 #1
0
        private void UpdateSelectionState()
        {
            navMenuList.SetSelectedItem(null);
            bottomNavMenuList.SetSelectedItem(null);

            INavigationBarMenuItem itemToHighlight = null;
            ViewModelArgs          viewModelArgs   = null;

            var parameter = _lastSourcePageEventArgs?.Item2 as string;

            if (parameter != null)
            {
                viewModelArgs = SerializationHelper.Deserialize <ViewModelArgs>(parameter);
            }

            // We only highlight the current page in the navigation bar
            // if navigation arguments tell us to.
            if (viewModelArgs == null ||
                viewModelArgs.HighlightOnNavigationBar)
            {
                itemToHighlight =
                    (from p in _viewModel.NavigationBarMenuItems.Union(_viewModel.BottomNavigationBarMenuItems)
                     where p.DestPage == _lastSourcePageEventArgs?.Item1
                     select p)
                    .SingleOrDefault();
            }

            togglePaneButton.Background = itemToHighlight == null ?
                                          new SolidColorBrush((Color)Application.Current.Resources["AppAccentLightColor"]) :
                                          new SolidColorBrush(Colors.White);

            ListViewItem container;

            if (navMenuList.Items != null && navMenuList.Items.Contains(itemToHighlight))
            {
                container = (ListViewItem)navMenuList.ContainerFromItem(itemToHighlight);
            }
            else
            {
                container = (ListViewItem)bottomNavMenuList.ContainerFromItem(itemToHighlight);
            }

            // 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);
            bottomNavMenuList.SetSelectedItem(container);

            if (container != null)
            {
                container.IsTabStop = true;
            }
        }
예제 #2
0
        private void UpdateSelectionState(Type sourcePageType)
        {
            navMenuList.SetSelectedItem(null);
            bottomNavMenuList.SetSelectedItem(null);

            INavigationBarMenuItem item = (from p in _viewModel.NavigationBarMenuItems.Union(_viewModel.BottomNavigationBarMenuItems)
                                           where p.DestPage == sourcePageType
                                           select p)
                                          .SingleOrDefault();

            togglePaneButton.Background = item == null ?
                                          new SolidColorBrush((Color)Application.Current.Resources["AppAccentLightColor"]) :
                                          new SolidColorBrush(Colors.Transparent);

            ListViewItem container = null;

            if (navMenuList.Items != null && navMenuList.Items.Contains(item))
            {
                container = (ListViewItem)navMenuList.ContainerFromItem(item);
            }
            else if (bottomNavMenuList.Items != null && bottomNavMenuList.Items.Contains(item))
            {
                container = (ListViewItem)bottomNavMenuList.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);
            bottomNavMenuList.SetSelectedItem(container);

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