Bug 51509 - NavigationPage.SetHasNavigationBar false doesn't work inside MasterDetailPage
Summary: NavigationPage.SetHasNavigationBar false doesn't work inside MasterDetailPage
Status: IN_PROGRESS
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows (show other bugs)
Version: 2.3.4
Hardware: PC Windows
: High normal
Target Milestone: ---
Assignee: Chris King
URL:
: 51646 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-01-13 14:05 UTC by Christian Schwarz
Modified: 2017-10-01 18:08 UTC (History)
16 users (show)

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


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

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

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 2.3.2.127

Forms 2.3.4-pre1: BAD
Forms 2.3.3.180: BAD
Forms 2.3.2.127: 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 2.3.4.224
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)

XF 2.3.4.224
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 2.3.4.247.
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 2.3.4.247. 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 2.3.4.247 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
Hi,

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.

Thanks,
Ibon
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
Hi,

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):

<MasterDetailPage.Master>
        <ContentPage Title="Menu" x:Name="master">


Crashing code:

<MasterDetailPage.Master>
        <ContentPage x:Name="master">

Also crashing:

<MasterDetailPage.Master>
        <ContentPage Title="" x:Name="master">


https://image.prntscr.com/image/ycaLvs3MTVuJBuxt9Kf0FA.png


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,
Ibon
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:

http://prntscr.com/fmc897

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

Thank you.

Regards,
Iker
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 2.4.0.266-pre1 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.

#if WINDOWS_UWP
            System.Threading.Tasks.Task.Delay(300).ContinueWith(t =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    var mdPage = (MasterDetailPage)Parent.Parent;
                    mdPage.IsPresented = true;
                    mdPage.IsPresented = false;
                });
            });
#endif

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.

Note You need to log in before you can comment on or make changes to this bug.