Search code examples
uwptemplate10

Template 10: Hide HamBurgerMenu if no internet


I am devloping an uwp app in which if there is no internet then the user is shown an error no internet connection at start.So I checked for internet connection if not then i did this in my App.xaml.:

 public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
    {
        // long-running startup tasks go here
        await Task.Delay(TimeSpan.FromSeconds(6));  
           if (!NoInternet)
            {


                NavigationService.Navigate(typeof(Views.Error));
            }             
            }         
        await Task.CompletedTask;
    }

Now when no internet connection is there then it navigates to my Error Page but the HamburgerMenu is still visible.How do i hide the HamburgerMenu.?I am using HamburgerMenu Template of Template10.Thanks in advance!.


Solution

  • I ran into similar problem for my app.Assuming that you have not edited shell.xaml.cs and also the Hamburgermenu name,just add this into shall.xaml.cs

       public HamburgerMenu _THamburgerMenu
        {
            get { return MyHamburgerMenu;}
    
            set { MyHamburgerMenu = value;}
        }
    

    and your app.xaml.cs should be like this:

    public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
    {
        // long-running startup tasks go here
        await Task.Delay(TimeSpan.FromSeconds(6));  
           if (!NoInternet)
            {
    
                Shell.Instance._THamburgerMenu.IsFullScreen = true;
    
                NavigationService.Navigate(typeof(Views.Error));
            }             
            }         
        await Task.CompletedTask;
    }
    

    Ps:add using youappname.Views in app.xaml.cs