【问题标题】:Navigation titleView not showing in ContentPage导航标题视图未显示在 ContentPage 中
【发布时间】:2021-11-21 10:08:21
【问题描述】:

Xamarin 新手,我试图在我的跨平台应用程序中创建自定义导航栏。我需要在三个内容页面之一中隐藏导航 titleView。

NavigationPage.HasNavigationBar="false"

我还使用了底部工具栏 android:TabbedPage.ToolbarPlacement="Bottom" 在 MainPages.xaml。 当我尝试在其他两个选项卡上添加标题时,顶部栏没有任何更改,但它显示为引用每个内容页面的底部选项卡的标题。 我已经在与正确内容页面相关的 xaml 中尝试了上面的代码

<ContentPage ... Title="Test"...>...</ContentPage

以及上面的代码在cs上:

我。关于.cs

Title = "Test";

二。 MainPages.cs

itemsPage = new About()
                    {
                        Title = "Test"
                    };

我也在添加与情况相关的图片

>>> Top NavigationBar is blank, the changes are applied to the bottomBar

当我尝试使用 Navigation.TitleView 进行自定义更改时,如下所示:

<NavigationPage.TitleView>       
     <Label Text="Tests" TextColor="Black"/>
</NavigationPage.TitleView>

...即使我设置了NavigationPage.HasNavigationBar="true",无论如何它也不起作用。结果在顶部和底部栏中没有任何内容。

我也在添加与情况相关的图片

>>>No changes applied at Top or Bottom bar

我不确定在第一个选项卡中隐藏 NavigationBar 时是否有任何步骤有误。我也对styles.xml进行了即时更改,我认为不是,反正下面是一段:

<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>

【问题讨论】:

  • App.xaml.cs 中的 MainPage 是什么?你在使用 NavigationPage 吗?
  • MainPage = new NavigationPage(new MainPages(status)); @JuanSturla
  • 您介意与我们分享一个基本的、最小的测试项目吗?您可以将其上传到 github 并在此处附上链接。

标签: css xaml xamarin xamarin.forms xamarin.android


【解决方案1】:

尝试使用ToolbarItems:

<ContentPage.ToolbarItems>
        <ToolbarItem Text="Title" Order="Primary" Priority="0" />
        <ToolbarItem IconImageSource="img" Order="Primary" Priority="1" />
        <ToolbarItem Text="Something" Order="Primary" Priority="2" />
</ContentPage.ToolbarItems>

【讨论】:

  • 这些是工具栏项目,我的问题是三个主要导航的标题内容页面。
猜你喜欢
  • 2017-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-23
  • 1970-01-01
  • 1970-01-01
  • 2020-03-15
  • 1970-01-01
相关资源
最近更新 更多