コード例 #1
0
        // Overrides

        protected override void NavButton_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            if (b != null)
            {
                // If the button links to a page, navigate to the page.
                PageInfo pageInfo = (PageInfo)b.DataContext;
                if (pageInfo == null)
                {
                    return;
                }

                // If the button links to a page, navigate to the page.
                if (pageInfo.PageType != typeof(Type))
                {
                    if (pageInfo.Data == null && NavigationRootPage.RootFrame.CurrentSourcePageType != pageInfo.PageType)
                    {
                        NavigationRootPage.RootFrame.Navigate(pageInfo.PageType);
                        NavigationRootPage.Current.TopAppBar.IsOpen = false;
                    }
                    else if (pageInfo.Data != null)
                    {
                        NavigationRootPage.RootFrame.Navigate(pageInfo.PageType, pageInfo.Data.ToString());
                        NavigationRootPage.Current.TopAppBar.IsOpen = false;
                    }
                }
                else
                {
                    NavToggleButton toggleButton = b as NavToggleButton;
                    if (toggleButton != null)
                    {
                        if (toggleButton.Toggle == this.currentCheckedToggleButton)
                        {
                            this.HideSecondLevelNav();
                        }
                        else
                        {
                            if (SecondLevelNavRow.Visibility == Windows.UI.Xaml.Visibility.Visible)
                            {
                                this.HideSecondLevelNav();
                            }

                            toggleButton.Toggle.IsChecked   = true;
                            this.currentCheckedToggleButton = toggleButton.Toggle;
                            return;
                        }
                    }
                }
            }
        }
コード例 #2
0
        protected override Button GetButton(PageInfo pageInfo)
        {
            if (pageInfo.ChildData == null)
            {
                return(base.GetButton(pageInfo));
            }
            else
            {
                NavToggleButton newButton = new NavToggleButton();
                newButton.DataContext = pageInfo;
                newButton.Content     = pageInfo.Title;
                newButton.Click      += NavButton_Click;
                newButton.Style       = (Style)this.Resources["NavToggleButtonStyle"];

                return(newButton);
            }
        }