0
votes

In my Items page (of a MAsterDetail forms), my app have a set of button to navigate each second page. How can opne the second page having access to the lateral menu by burger icon?

my code to navigate to second page is
Application.Current.MainPage = new NavigationPage(new MySecondPage());

 async void ButtonClicked(object sender, EventArgs e)
        {

            Button btn = sender as Button;

            int btnId = int.Parse((sender as Button).CommandParameter.ToString());

            switch (btnId)
            {
                case (1):
                    Application.Current.MainPage = new NavigationPage(new MySecondPage());
                        break;

                case (2):
                    // button 2 action


                case (3):
                    // button 3 action

                    break;

            }


        }

Thanks in advance.

1

1 Answers

2
votes

You are doing it in a wrong way, and the issue with your code is that you are "reseting" navigation stack by using: Application.Current.MainPage = new NavigationPage(new MySecondPage());

So every time you are setting MySecondPageas a main page in your app.

To achieve what you want just use:

Detail = new NavigationPage(new MySecondPage());

Using MasterDetail page like this you will set your page as a Detail.

Try code above and you should be fine. Also 2 years ago I made this little sample with MasterDetail main page maybe it will be helpful for you too. You can find it here.

Wishing you lots of luck with coding!