2
votes

I have a MasterDetailPage that contains the following constructor:

    public MainPage()
    {
        NavigationPage.SetHasNavigationBar(this, false);
        NavigationPage.SetHasBackButton(this, false);
        InitializeComponent();

        MessagingCenter.Subscribe<JobsPage>(this, "OpenMenu", (sender) => {
            IsPresented = true;
        });

        MasterPage.ListView.ItemSelected += ListView_ItemSelected;
        this.MasterBehavior = MasterBehavior.Popover;
        App.NavPage = new NavigationPage(new JobsPage() { Title = "Jobs" });
        Detail = App.NavPage;
    }

As you can see, I've set SetHasNavigationBar and SetHasBackButton to false.

On a different page (a ContentPage, not a MasterDetailPage), I did the same thing in the constructor:

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

On my ContentPage, this works fine, as shown below.

enter image description here

On my MasterDetailPage, however, I'm still seeing the Navigation bar.

enter image description here

How can I fix this?

4

4 Answers

1
votes

Not sure how is structured your navigation, but try this:

public MainPage()
{

        InitializeComponent();

        MessagingCenter.Subscribe<JobsPage>(this, "OpenMenu", (sender) => {
            IsPresented = true;
        });

        MasterPage.ListView.ItemSelected += ListView_ItemSelected;
        this.MasterBehavior = MasterBehavior.Popover;

        var navPage = new NavigationPage(new JobsPage() { Title = "Jobs" });
        NavigationPage.SetHasNavigationBar(navPage, false);
        NavigationPage.SetHasBackButton(navPage, false);

        App.NavPage = navPage;
        Detail = App.NavPage;
}
0
votes

As far as I know, a Master-DetailPage does not support Navigation Bars. It is the root container where you can place your content pages. These pages can now contain a navigation bar that can redirect you to the root page in the Master-DetailPage.

0
votes

I faced similar issue and i had a work-around for this.

Set the Detail twice.

// 1st time
var jobPage = new JobsPage() { Title = "Jobs" };
Detail = jobPage;

// 2nd time
var navPage = new NavigationPage(jobPage, false);
Detail = navPage;

Set the 1st in constructor and 2nd in OnAppearing.

Try it.

0
votes

Try setting those lines in detail page of the MasterDetailPage

In code behind

NavigationPage.SetHasNavigationBar(this, false);

In xaml

NavigationPage.HasNavigationBar="False"