1
votes

I am creating an application in Xamarin Forms (4.0) for Android (Android 8.1). My main page is a MasterDetailPage where I set the detail page to:

this.Detail = new NavigationPage(new SomePage());

When I want to navigate the detail to another page (so that the 'back' button works correctly) I just do:

this.Detail.Navigation.PushAsync(new NavigationPage(new SomeOtherPage());

This all works fine but I am left with an additionl navigation bar with the back button:

If I do NavigationPage.SetHasBackButton(this, false); the back button goes away but the navigation bar is left so I have a big blue rectangle on top of my page. If I do NavigationPage.SetHasNavigationBar(this, false); then both the navigation bar and the titlebar (with hamburger menu) dissappear! Is there a way to just hide the navigation bar with the back button but leave the master/detail title bar (with hamburger menu)?

4
What is hamburger menu is no longer visible. Only the title is left? Can you add more code or a screenshot? One instance of NavigationPage is enough for you as Jason said.Jack Hua
Did you tested it on real device?Anand
Sorry I did not see your comment. No I have not tested it on a real device. Copy/pasted from my other comment: 'You can see the effect if you create a new Cross-Platform Mobile App (Xamarin.Forms) in VS2017/2019. The generated application has a master/detail page with a list of items. If you tap on an item your proceed to the item details form. When this happens you loose the master/detail hamburger menu. You can avoid this by wrapping the detail page in NavigationPage, however this shows an extra back button bar (as visible in my original screenshot)'.Dalibor Čarapić
The effect I want to achieve is to have the Master/detail menu available all the time, even if the Detail page navigates somewhere else. This actually works quite nicely if I wrap the detail page into NavigationPage ... but I get two titlebars.Dalibor Čarapić

4 Answers

1
votes

It seems that the way I've tried to make it work is not really supported by Xamarin Forms. If you navigate the Detail away to another page you effectively loose access to the Master part of the MasterDetailPage (at least on some devices). My attempt to avoid this by wrapping the target Detail page into another NavigationPage works in the Emulator but that is simply by accident.

0
votes

you only need one instance of NavigationPage

this.Detail.Navigation.PushAsync(new SomeOtherPage());
0
votes

You can assign the new MasterDetailPage to the root and then handle back pressed. As this isn't suppose to work you must hack a bit.

0
votes

Make sure that your MainPage is set only to MasterDetailPage. Once, I had a case that somebody did something like this:

MainPage = new NavigationPage(new MasterDetailPage());

Of course, it should be defined like:

MainPage = new MasterDetailPage();

Then, your DetailPage should be defined only once as it follows:

Detail = new NavigationPage(new MyPage());