本文介绍了隐藏MasterDetailPage上的导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MasterDetailPage,其中包含以下构造函数:

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

如您所见,我将SetHasNavigationBarSetHasBackButton设置为false.

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

在一个不同页面(一个ContentPage,而不是一个MasterDetailPage)上,我在构造函数中做了同样的事情:

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

在我的ContentPage上,它可以正常工作,如下所示.

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

但是,在我的MasterDetailPage上,我仍然看到导航栏.

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

我该如何解决?

推荐答案

不确定导航的结构,但是请尝试以下操作:

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

这篇关于隐藏MasterDetailPage上的导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-21 15:39