user1089031 user1089031 - 1 year ago 324
C# Question

Xamarin Forms Master Detail Page Main Page Hide Navigation Bar

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?

Answer Source

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


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

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

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

            if (ViewController.ParentViewController.NavigationController.NavigationBar != null)
                ViewController.ParentViewController.NavigationController.SetNavigationBarHidden(true, false);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download