Search code examples
c#xamarinnavigationxamarin.formsmaster-detail

How to navigate pages without navigation stack in master detail page?


I've created a PCL project where I'm having a main page where the person can navigate to three sections and each seciton has a login page. After logging in the master detail page comes which has number of pages to navigate.

Navigation Page
  Main Page (can be popped)   
   Login (can be popped)    
    Master Page
     Detail Page
      Navigation Page
       SubPages

When I'm navigating to detail pages, then it shows the error that android can't have two navigation stacks. How should I navigate to master page without navigation page or what should I do?


Solution

  • You can directly set the MainPage of the App class when you are showing your main page or login page, and wrap your detail page in NavigationPage.

    //show main page 
    MainPage = new MyMainPage();
    
    //show login page
    MainPage = new LoginPage ();
    
    //show master detail 
    MainPage = new MyMasterDetailPage
               {
                   MasterPage = new MyMasterPage()
                   DetailPage = new NavigationPage(MyDetailPage)   
               }