Migrated from https://bugzilla.xamarin.com/show_bug.cgi?id=51509
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.
NavigatonBar is visible.
This is fixed on the latests
Hi,
We have updated to the latest version of Xamarin Forms (2.5.0.122203) but we still have the same error with the navigation bar.
We have set:
NavigationPage.SetHasNavigationBar(detailContent, false);
But same error.
Is there any other property to set?
Thank you.
Regards,
Iker
@ikerhg can you upload a test case i used this one here https://github.com/jkastner/XamFormsBugSample_51509 and this works fine
Hi @rmarinho ,
We are trying to use a custom bar and open menu (so we need popover) when clicking a custom button in our bar. So we need to hide default from the start. This custom bar is only a stacklayout located in the top of the page with a button.
If we set Title to empty string and navigation bar to false in "BrowseEntriesPage.xaml" we still continue seeing the menu bar:
Is there any way to hide the navigation bar always and show popover menu when clicking a button.
Thank you very much.
Regards,
Iker
Hi again @rmarinho ,
If we downgrade Xamarin.Forms to 2.3.2.127, it is working as we want, navigation bar is hidden from the begining and we can show popover menu when we want:
Thank you.
Regards,
Iker
Please upload a short sample so we can look at it.
Thanks
Hi @rmarinho,
I've tested this. You can check with your own project:
Change BrowseEntriesPage xaml from this:
ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Title="Browse Entries Page"
BackgroundColor="DarkGray"
x:Class="Test_NavPage.BrowseEntriesPage"
to this:
ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Title=""
NavigationPage.HasNavigationBar="False"
BackgroundColor="DarkGray"
x:Class="Test_NavPage.BrowseEntriesPage"
When you launch the project you'll see how the top bar appears with empty title.
But if you downgrade Xamarin.Forms to the last working version before the bug appeared (2.3.2.127), with the same code (you'll only need to remove or change a couple of BackgroundColor properties) the top bar won't appear (as expected since we are setting it that way).
Do you need me to upload your project with doengraded Xamarin version and those changes in BrowseEntriesPage?
Hi again @rmarinho,
Here you have the downgraded (working) version. Check how the bar does not appear on first page with this Xamarin Forms version.
I haven't added any custom bar or means to show menu, it is not necessary dor the bug reproduction proposal.
Hi @rmarinho,
Shouldn't this bug be reopened?
Thanks,
Ibon
I can confirm I still see this in our UWP app with the very latest Xamarin Forms update.
@ibonsanvicente this bug is about not being able to hide the bar, but seems your are complaining the oposite. that it doesn't show the bar?!
Oh ok this is 2.3.2 .. gotcha.
Just a reminder of more background where this came from: https://bugzilla.xamarin.com/show_bug.cgi?id=51509. It is an issue in UWP where the bar does not hide but it should be hidden. It seems to hide properly after toggling the master view on/off.
@ibonsanvicente seems this only happens when using MasterBehavior="Popover" right?
@DennisWelu @ikerhg are you using Popover too ?
Hi @rmarinho,
Seems so: in our project we use Popover. If I change to Default then the bar does not appear, though Popover is the menu behaviour we need.
Cheers,
Ibon
@rmarinho Yes true, Popover is what we are using as well.
Behavior has changed but...anyone else still not seeing it all work right? My MasterDetailPage.MasterBehavior is set to MasterBehavior.Popover
...but with XF 3.1 out of the box for me SetHasNavigationBar(..., false) is still leaving a blank space at the top. Then if I toggle the popover menu open/closed the space at the top goes away and is now replaced by a space at the bottom. (The bottom space showing up is new behavior from previous... ) Almost as if the page content layout was not redone but it shifts up the height of the removed bar...
This is not working for me in the latest XF 3.3.0.967583 . @rmarinho can you reopen pls?
let w = MainWindowV()
let np = NavigationPage(w)
do NavigationPage.SetHasNavigationBar(np, false)
do base.MainPage <-
MasterDetailPage(Master = ContentPage(Title = "Master"), Detail = np, MasterBehavior = MasterBehavior.Popover)
Also, it's odd that to remove the bar we need to wrap a ContentPage in a NavigationPage. Better to have a property on MasterDetailPage instead.
Same behaviour for us with XF 3.3.0.967583
Please reopen this issue. On UWP this is still not working. To prevent flashing of navigation bar on Android I'm using XAML instead of code behind.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Actemium.SCS.FieldForce.MobileClient.Views.AlertPage"
Title="Error"
NavigationPage.HasNavigationBar="False">
This work perfect in Android, but UWP has the issue that it does not remember the setting. Each time that I navigate back the navigation bar is displayed including the title and hamburger icon. When I navigate to a child page, then a blank navigation bar is displayed.
I can call code NavigationPage.SetHasNavigationBar(this, false); each time a page is created, but this does not fix the back button press scenario. Then the full navigation bar is still displayed. Till now I can not find a workaround to get this fixed.
This bug prevents me from building a custom navigation bar. So please reopen.
Thanks.
Tested on latest Xamarin Forms version 3.4.0.1008975.
@davidortinau @rmarinho @samhouts
I managed to implement a nasty patch.
I implemented the following code in each Page.
protected override void OnAppearing()
{
base.OnAppearing();
// Disable navigation bar.
// Note: Only on UPW and WPF because of a bug.
if (Device.RuntimePlatform == Device.UWP || Device.RuntimePlatform == Device.WPF)
{
NavigationPage.SetHasNavigationBar(this, true);
NavigationPage.SetHasNavigationBar(this, false);
MasterDetailPage mainPage = App.Current.MainPage as MasterDetailPage;
if (mainPage != null)
{
mainPage.MasterBehavior = MasterBehavior.Default;
mainPage.MasterBehavior = MasterBehavior.Popover;
mainPage.IsPresented = false;
}
}
}
I have to call SetHasNavigationBar twice. Once to activate and again to deactivate. This still displays a blank navigation bar.
To hide the blank navigation bar I toggle MasterBehavior to Default and back to Popover.
This works fine for UWP without flashing screen. At least that I can see.
For Android I will go for the following XAML code to prevent screen flashing.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Actemium.SCS.FieldForce.MobileClient.Views.AlertPage"
Title="Error"
NavigationPage.HasNavigationBar="False">
Still hope this bug is going to be fixed.
+1 @nicovos
Actually setting SetHasNavigationBar false/true doesn't help if navigation page is a child of TabbedPage: in UWP navigating back to tab with NavigationPage (which nav bar is hidden) still preserves space for that hidden nav bar. Haven't found workaround for this issue on TabbedPage so far.
I've created separate issue since there is no attention here.
This issue happens on UWP with Xamarin.Forms 3.4 lastest stable. Also happens with WPF.
NavigationPage.SetHasNavigationBar = false, doesn't hide bar in MasterDetailPage.
Most helpful comment
I managed to implement a nasty patch.
I implemented the following code in each Page.
I have to call SetHasNavigationBar twice. Once to activate and again to deactivate. This still displays a blank navigation bar.
To hide the blank navigation bar I toggle MasterBehavior to Default and back to Popover.
This works fine for UWP without flashing screen. At least that I can see.
For Android I will go for the following XAML code to prevent screen flashing.
Still hope this bug is going to be fixed.