【问题标题】:Remove ActionBar Top Heading in XamarinForms删除 Xamarin 表单中的操作栏顶部标题
【发布时间】:2021-11-02 14:45:14
【问题描述】:

我已经在 Xamarin Forms 中实现了一个带有导航抽屉的仪表板。我想删除下图中的蓝色部分并将切换按钮移动到我的设计中。请帮忙

我已经使用 Shell Flyout 实现了如下的导航 Drawer/Flyout

NavigationPage.SetHasNavigationBar(this, false);

我尝试使用来自另一个堆栈溢出问题的上述代码行,但它不起作用

【问题讨论】:

    标签: xamarin xamarin.forms


    【解决方案1】:

    我认为 Shell 是隐藏此 ActionBar 的错误。我在 Shell 中有一个项目,我尝试了一切来隐藏它,但没有任何效果。所以我只是处理它:

    <ContentPage.ToolbarItems>
            <ToolbarItem Text="MyTitle" Order="Primary"/>
            <ToolbarItem IconImageSource="img1.png" Order="Primary"/>
            <ToolbarItem IconImageSource="img2.png" Order="Primary"/>
            <ToolbarItem IconImageSource="img3.png" Order="Primary"/>
    </ContentPage.ToolbarItems>
    

    如果你愿意,你可以移除你的actionBar并使用Shell的这个ActionBar编辑它。

    【讨论】:

      【解决方案2】:

      根据截图,你有两个弹出页面。

      1. 如果您使用 Shell 模板,当您将 FlyoutDisplayOptions 设置为 AsMultipleItems 时,默认情况下它有一个弹出页面。

        外壳弹出窗口:https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/flyout

      2. 如果您只想要一个没有 Shell 模板的弹出窗口,东方式是使用 FlyoutPage

        请注意,如果您在 App.xaml.cs 中使用 NavigationPage,它将显示如下所示的栏。所以在使用 Flyoutpage 时不要使用它。

          MainPage =  new NavigationPage(new Flyoutpage());
        

        FlyoutPage:https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/flyoutpage

      【讨论】:

        【解决方案3】:

        使用 Shell.NavBarIsVisible="False" 内部内容页面将起作用 Shell.Current.FlyoutIsPresented = true; 在按钮中单击将打开抽屉。这个答案是在

        中找到的

        https://docs.microsoft.com/en-us/answers/questions/349760/how-to-hide-navigation-bar-on-xamarin-forms-when-u.html

        【讨论】: