Remove navigation bar on Xamarin Forms app with Caliburn.Micro

混江龙づ霸主 提交于 2020-06-11 16:14:47

问题


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?


回答1:


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



回答2:


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



回答3:


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

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


来源:https://stackoverflow.com/questions/36656895/remove-navigation-bar-on-xamarin-forms-app-with-caliburn-micro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!