I got a little App where I need to Swap from a ContentPage
to a MasterDetailsPage
.
MainPage = new NavigationPage(new MyContentPage());
Now if the login succeed I want to change the Root to MainPage = new NavigationPage(new MyMasterDetailpage());
.
The MasterDetailsPage is shown, but the Button in the Navigation bar is missing then.
If I just use
Navigation.PushModalAsync(new MyMasterDetailpage());
I dont even get an Navigationbar, with
Navigation.PushModalAsync(new NavigationPage(new MyMasterDetailpage()));
The menu icon is missing again.
Anything I can do here?
Update
It seems that my problem is only on Android, didn't know that the new NavigationPage(new MyDetailView)
hamburger only appears on android.
If you are pushing the MasterDetailPage using the PushModalAsync then navigation bar will not be shown as it will open the page as a Modal in fullscreen mode. If you push the page as :
then u will get a back button on the navigation bar clicking it will move you backward to the page before. So your hamburger icon will not be visible.
The option is to set your MasterDetailPage as your MainPage
If you want your Page which was added before the MasterDetailPage you can override the OnBackPressed() method in your android activity and push your page in the navigation stack and Pop your current MasterDetailpage.
NavigationMenu appears in
MasterDetailPage
when theDetail
page is aNavigationPage
. So rather than pushing MasterDetailsPage to Navigation stack, you may set it as MainPage. And then within MasterDetailPage, you need to add DetailPage within a NavigationPage. You can set the Icon for the menu with Icon property ofMasterPage
Here is an example below,By setting the icon of your Master page you should get the image you supply as a button in the navigationbar.
Try someting like this in your MyMasterDetailpage
I had the same problem. But the solution was to make different the process. You wants to load, initially, the login view and then you show the view of the MasterDetail. I solved this as follows:
When you start the application, I create the view of the MasterDetail and immediately show the login view as a dialog, if the login is successful simply close the dialog. The code would look something like this:
When the login is successful simply called the
PopModalAsync()
method