Bug 51509 - NavigationPage.SetHasNavigationBar false doesn't work inside MasterDetailPage
Summary: NavigationPage.SetHasNavigationBar false doesn't work inside MasterDetailPage
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.3.4
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Chris King
: 51646 ()
Depends on:
Reported: 2017-01-13 14:05 UTC by Christian Schwarz
Modified: 2017-12-20 01:44 UTC (History)
20 users (show)

Tags: uwp ac navigationpage SetHasNavigationBar masterdetailpage
Is this bug a regression?: Yes
Last known good build:

Reproduction (339.55 KB, application/x-zip-compressed)
2017-01-13 14:05 UTC, Christian Schwarz
repro project (309.39 KB, application/zip)
2017-01-26 18:51 UTC, Jimmy [MSFT]
updated repro (4.49 MB, application/x-7z-compressed)
2017-06-20 18:03 UTC, Samantha Houts [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Christian Schwarz 2017-01-13 14:05:09 UTC
Created attachment 19325 [details]

Page masterContent = new ContentPage() { Title = "Master", BackgroundColor = Color.Red };
Page detailContent = new ContentPage() { BackgroundColor = Color.Blue };

NavigationPage.SetHasNavigationBar(detailContent, false);

MasterDetailPage masterDetail = new MasterDetailPage()
	Master = masterContent,
	Detail = new NavigationPage(detailContent)

MainPage = masterDetail;

NavigatonBar shouldn't be visible.

Works fine on Android and iOS.
Comment 2 Jimmy [MSFT] 2017-01-26 18:51:03 UTC
Created attachment 19494 [details]
repro project

I am able to reproduce this issue with the attached repro project. With Forms 2.3.4-pre1, the navigation bar is not hidden on UWP.

Windows 8.1 and WP8.1 does not experience this issue.

### Regression Status
The last Forms version without this issue is

Forms 2.3.4-pre1: BAD
Forms BAD
Forms GOOD

I've attached a fixed version of the original repro as it was not building successfully
Comment 3 Paul DiPietro [MSFT] 2017-02-15 05:00:40 UTC
*** Bug 51646 has been marked as a duplicate of this bug. ***
Comment 4 tchadwick 2017-04-06 20:39:18 UTC
This is not resolved and fixed, it's true that the root page of the NavigationPage that is set as the detail doesn't show a NavigationBar, however, once a new page is pushed on the navigation stack, it's call to hide the navigation bar is ignored and the navigation bar appears over the page.  This is using Forms
Comment 5 tchadwick 2017-04-06 20:41:24 UTC
So Detail = NavigationPage(RootPage);  With RootPage setting the navigation bar as hidden does hide the Navigation Bar, however Detail = NavigationPage(RootPage -> SecondPage); with SecondPage setting the navigation bar as hidden is not honored.
Comment 6 Sascha Leier 2017-04-07 12:31:18 UTC
In my experience this bug works with the second and third page but it ignores the flag if you navigate back to a page.

RootPage->SecondPage(navigationbar is gone)->ThirdPage(navigationbar is gone)->SecondPage(navigationbar is visible but NavigationPage.GetHasNavigationBar returns false)

Comment 7 Paul Fitzgerald 2017-05-17 09:24:21 UTC
Has anyone figured out a workaround for this?
Really don't want to revert back to 2.3.2. Not sure which version is worse.
Comment 8 dengere 2017-06-05 16:07:08 UTC
I can't find way for
I use xaml attributes. NavigationPage.HasNavigationBar="False"
Comment 9 Jimmy [MSFT] 2017-06-07 17:47:09 UTC
Hey all, I am not able to reproduce the issues mentioned in comment 5 and comment 6 with Forms The root and subsequent pages all respect the SetHasNavigationBar setting and the navbar stays hidden even when navigating back through the stack.

Can someone attach an updated project that reproduces this issue with or higher so we can confirm that this is still an issue? Thanks!
Comment 10 tchadwick 2017-06-07 20:34:53 UTC
@Jimmy thank you for the update, I have isolated the issue to when the MasterDetailPage is being presented within a NavigationPage using Navigation.PushModalAsync(). (so modally) And then has it's detail set to a navigation page that then pushes a page on to the stack. If the MasterDetail Page is pushed regularly using Navigation.PushAsync() no issue and the navigation bars are properly hidden.  So to summarize: NavigationPage(rootPage) -> PushModal(MasterDetailPage) -> Detail.Navigation.Push(Page2) shows navigation bar.
Comment 11 Melbourne Developer 2017-06-20 06:04:04 UTC
Please fix this bug
Comment 12 Ibon 2017-06-20 07:49:29 UTC

We've been holding a release for some time now and can't hold anymore. This bug has been around for a long time now and for us it is a real disaster.

We use a custom bar for our app and UWP won't hide the defaut one anymore since 2.3.2 

This is how our app looks now as result: http://oi64.tinypic.com/11bjd5d.jpg

We will have to downgrade in order to release UWP, which will cause losing other fixes which were solved in current version and having to workaround those all over again.

Please, fix this issue.

Comment 13 Samantha Houts [MSFT] 2017-06-20 17:55:17 UTC
The NavigationPage will always show the NavigationBar if the Page it is hosting has a Title.

Please remove the Title. The NavigationBar should no longer be present.

Thank you!
Comment 14 Samantha Houts [MSFT] 2017-06-20 18:03:11 UTC
Created attachment 23014 [details]
updated repro

Project displays properly, no nav bar. If you uncomment the line adding the Title, then the nav bar will appear.
Comment 15 Ibon 2017-06-21 07:16:16 UTC

Still a problem here: I've run the project attached in comment 14. 

It declares the ContentPage programatically and sets no Title, so the proposed fix works in this scenario:

ContentPage newContentPage = new ContentPage { Content = new Label { Text = "Detail" }, BackgroundColor = Color.Red };

BUT, we have our Content pages declared in xaml and, should I remove Title property or even leave it blank, I'd get an error:

Working code (but bad Bar behaviour):

        <ContentPage Title="Menu" x:Name="master">

Crashing code:

        <ContentPage x:Name="master">

Also crashing:

        <ContentPage Title="" x:Name="master">


Would someone please confirm this or I am doing something wrong?

Should this behaviour be confirmed, either the bug should remain open or a new bug claiming for ContentPage without Title in xaml support be created.

Best regards,
Comment 16 Ibon 2017-06-21 07:29:22 UTC
In any case I'd like to thank Samantha Houts, at least we can workaround now: it is not ideal because there is some xaml code but we'll comment it for the time being and add a new C# class to replace and declare ContentPage programatically without Title.
Comment 17 Iker 2017-06-21 09:19:30 UTC
Hi Samantha,

I have checked your solution but if I add Popover master behaviour, navigation bar appears again:

"MasterBehavior = MasterBehavior.Popover;"

I have done this in your project and the result is the following:


Is there any other option? We need to manage when the menu opens/closes.

Thank you.

Comment 18 tchadwick 2017-06-21 15:31:45 UTC
I don't think for the Master Page that you'll have any options till this bug is fixed.  The Master Page has to be set to a page that has a title, so you might be out of luck.  The only other thing I can think to try, would be to use a NavigationPage as your master, setting the NavigationPage's title, and then in the root page / your content page for the master, remove the title.
Comment 19 tchadwick 2017-06-21 15:37:20 UTC
BTW Xamarin, this is not resolved answered, the bug exists, it is tied to whether or not the Title is set for the page in the NavigationPage.  This is easy enough to get around when you don't need the title set, but for the MasterDetail Page, where the Master page requires the title be set, there is no work-around and requires your intervention to fix.
Comment 20 Ibon 2017-06-23 09:01:49 UTC
Shouldn't the status be changed? This is not fixed.
Comment 21 Samantha Houts [MSFT] 2017-06-23 17:30:42 UTC
Fair enough! We'll confirm the issue. Thanks!
Comment 23 Ibon 2017-08-23 07:31:13 UTC
Tested with and not yet fixed.

Is there any estimated date for this fix please?

This is affecting our release plan. Either we continue holding up UWP release (which we've done for too long now) or we go with a quite old Xamarin Forms version assumning some issues with labels etc which are fixed in newer releases.
Comment 24 Dennis Welu 2017-08-30 21:45:23 UTC
I found that if after enough time passes that toggling the master IsPresented on/off would cause the nav bar to go away. I put this in my Detail page constructor but could be in an Appearing event handler too.

            System.Threading.Tasks.Task.Delay(300).ContinueWith(t =>
                Device.BeginInvokeOnMainThread(() =>
                    var mdPage = (MasterDetailPage)Parent.Parent;
                    mdPage.IsPresented = true;
                    mdPage.IsPresented = false;

I tried doing ForceLayout instead but didn't seem to trigger it, just toggling the Master. It happens fast enough that its not visible to the eye but...a delay of 200 wasn't enough delay. So I'm guessing different systems will behave differently. Just a dirty hack to get by for now...
Comment 25 Nicholas Bauer 2017-10-01 18:03:17 UTC
I was going to post a new bug, with the nav bar disappearing when navigating backwards, but this appears to be it.

Also may be related to this apparently fixed issue? https://bugzilla.xamarin.com/show_bug.cgi?id=54649
Comment 26 Nicholas Bauer 2017-10-01 18:08:43 UTC
Can confirm that setting a title, even a space, keeps it from disappearing.
Comment 27 JKastner 2017-10-25 13:02:07 UTC
I'm seeing this as well when trying to replace the native app bar in our project. It's a blocking issue for us as well. Removing the Title on all pages seems to be the only workaround, which isn't feasible for our application.

I've created a minimal project that reproduces the issue, and placed it on github here:
Comment 28 JKastner 2017-10-25 14:19:20 UTC
Is there any kind of updated estimate for this issue?
Comment 29 jjtudu 2017-12-09 22:07:23 UTC
facing same issue
Comment 30 David Ortinau [MSFT] 2017-12-20 01:44:11 UTC
Migrated to https://github.com/xamarin/Xamarin.Forms/issues/1437

Please subscribe to that issue for future updates.