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?
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);
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 ContentPage
s
Shell.NavBarIsVisible="False"
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!
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With