Xamarin Forms Master Detail Page Main Page Hide Navigation Bar
Asked Answered
C

1

2

I cannot figure out how to hide the Navigation bar when setting my applications main page to a "master-detail" page. If the master-detail page is NOT the main page of the application then the navigation bar hides correctly, but no matter what I do I cannot hide the nav bar if it is the main page.

I have tried the following in the constructor of the master page, the detail page and in the overridden OnAppearing method of both but the nav bar never hides.

NavigationPage.SetHasNavigationBar( this, false ); NavigationPage.SetHasBackButton( this, false );

I have also tried similar logic directly in the XAML but it never hides. If I first set my MainPage to another page then just navigate forward to the master-detail page the nav bar hides correctly.

Any thoughts/ideas?

Collard answered 29/11, 2016 at 18:50 Comment(0)
C
2

For the android implementation, add the following to your MainActivity.cs:

global::Xamarin.Forms.Forms.SetTitleBarVisibility(Xamarin.Forms.AndroidTitleBarVisibility.Never);

For iOS, the process requires a custom renderer, but it's really basic:

public class iOSCustomMobilePageRenderer : PageRenderer
{
    public override void ViewWillAppear(bool animated) {
        base.ViewWillAppear(animated);


        if (ViewController != null && ViewController.ParentViewController != null && ViewController.ParentViewController.NavigationController != null) {

            if (ViewController.ParentViewController.NavigationController.NavigationBar != null)
                ViewController.ParentViewController.NavigationController.SetNavigationBarHidden(true, false);
        }
    }
}
Chatterjee answered 29/11, 2016 at 18:57 Comment(1)
I test in Android and hide status bar(bar where is hour, wifi, icons, ect)Romeoromeon

© 2022 - 2024 — McMap. All rights reserved.