Search code examples
uwpwindows-template-studio

How to hide NavigationView's PaneToggleButton in uwp


I'm using Windows template studio, in ShellPage.xaml, I can set NavigationView's PanToggleButton visible or not by using

IsPaneToggleButtonVisible=true/false;

And by default, my app will navigate to MainPage() after App started. When I navigate to Page1, I want to set PanToggleButton invisible.

How to do that?


Solution

  • Got it. In ShellPage.xaml.cs,

    private void Frame_Navigated(object sender, NavigationEventArgs e)
    {
        if (e.SourcePageType == typeof(Page1))
            navigationView.IsPaneToggleButtonVisible = false;
        else 
            navigationView.IsPaneToggleButtonVisible = true;
    }
    

    Frame_Navigated method can get the navigated page type, and then you can do some more thing.