27

When using the FormsApplication base class with a brand new Xamarin.Forms app using Caliburn.Micro, I end up with an empty navigation bar at the top of my screen. I assume it's being created by Caliburn.Micro somehow, because an out-of-the-box Xamarin.Forms app doesn't have that.

Is there any way I can use Caliburn.Micro with Xamarin.Forms without this navigation bar?

Brian Sullivan
  • 27,513
  • 23
  • 77
  • 91

7 Answers7

95

I have not used Caliburn.Micro, but I am assuming that it is wrapping your page with a NavigationPage, as what you describe is what would happen if so.

You should be able to hide that navigation bar by setting a simple attribute in your page like so:

<ContentPage NavigationPage.HasNavigationBar="false"
    ..... >
</ContentPage>

If you are not using XAML pages and doing all of your UI in code instead, then you can do it this way within your page constructor:

NavigationPage.SetHasNavigationBar(this, false);
Keith Rome
  • 3,208
  • 19
  • 15
  • 5
    For some reason the `NavigationPage.SetHasNavigationBar` isn't working any more but the XAML solution works well. – Rob Sanders Jan 31 '18 at 15:21
  • 2
    If this doesn't work, You're probably using a `Shell`, In that case try adding this line of code to each of your ContentPages `Shell.NavBarIsVisible="False"` – Sadra M. Feb 24 '21 at 15:45
8

If you are using a Shell, (if you chose any of Visual Studios three Templates when first creating your project, you probably are) NavigationPage.HasNavigationBar="False" won't work. Try adding this line of code to each of your ContentPages

Shell.NavBarIsVisible="False"
Sadra M.
  • 1,304
  • 1
  • 17
  • 28
2

This drove me nuts for a while as every answer I've seen for the code behind is a partial answer.

Lets say in your App.Xaml.cs file you have your NavigationPage constructor set like this:

MainPage = new NavigationPage(new Astronomy.MainPage());

You then have to go into the MainPage code behind and add code to remove the NavBar: you can't add the line to the app constructor.

public MainPage()
    {
        InitializeComponent();
        NavigationPage.SetHasNavigationBar(this, false);
    }

So glad I finally figured this out! It's been causing me a headache for a while!

Jason S
  • 33
  • 5
1

It works for me:

protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);
    this.Window.AddFlags(WindowManagerFlags.Fullscreen); // hide the status bar

                // Set our view from the "main" layout resource
    SetContentView(Resource.Layout.Main);

    int uiOptions = (int)Window.DecorView.SystemUiVisibility;

    uiOptions |= (int)SystemUiFlags.LowProfile;
    uiOptions |= (int)SystemUiFlags.Fullscreen;
    uiOptions |= (int)SystemUiFlags.HideNavigation;
    uiOptions |= (int)SystemUiFlags.ImmersiveSticky;

    Window.DecorView.SystemUiVisibility = 
     (StatusBarVisibility)uiOptions;
}
Bruno Peres
  • 15,845
  • 5
  • 53
  • 89
Sina
  • 575
  • 1
  • 5
  • 23
1

If you are using Xamarin Forms 3.x try this in the constructor

 SetValue(NavigationPage.HasNavigationBarProperty, false);
 InitializeComponent();
Shashank Shekhar
  • 3,958
  • 2
  • 40
  • 52
  • Could you edit this to make clear that this property has to be set on the page being *displayed*, not the page doing the displaying? I struggled with this for a while before figuring it out. – Le Mot Juiced Jun 03 '20 at 20:15
1

After updating the MvvmCross nuget packages(to 8.0.2) and Xamarin Forms neget packages (to 5.0.0), I need to put this option explicitly.

put NavigationPage.HasNavigationBar="False" on your xaml ComtentPage or MvxContentPage

Hyungkyu
  • 11
  • 1
-1

New Here! My first comment

Just too confirm that "Cedric Moore"s Answer works! Thank you, spent hours at this and this finally worked!

At the top of your Page(Located inside "Views" folder Default)

(AboutPage.xaml) is the starting one and the one i am using for this example.

Inside the <> of ContentPage, add Shell.NavBarIsVisible="False"

Example:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="YourNameHere.Views.AboutPage"
         xmlns:vm="clr-namespace:YourNameHere.ViewModels"
         Title="{Binding Title}"
         Shell.NavBarIsVisible="False">
Bejkon
  • 1