Brian Sullivan
Brian Sullivan

Reputation: 28563

Remove navigation bar on Xamarin Forms app with Caliburn.Micro

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?

Upvotes: 27

Views: 34337

Answers (7)

Hyungkyu
Hyungkyu

Reputation: 11


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

Upvotes: 1

Bejkon
Bejkon

Reputation: 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">

Upvotes: -1

Sadra M.
Sadra M.

Reputation: 1532

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"

Upvotes: 9

Jason S
Jason S

Reputation: 33

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!

Upvotes: 2

Shashank Shekhar
Shashank Shekhar

Reputation: 4178

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

 SetValue(NavigationPage.HasNavigationBarProperty, false);
 InitializeComponent();

Upvotes: 1

Sina
Sina

Reputation: 645

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;
}

Upvotes: 1

Keith Rome
Keith Rome

Reputation: 3228

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

Upvotes: 95

Related Questions