我设置了这个页面导航栏的可见性,我的标题就这样消失了. 但有一个BlueBar我可以导航回go .我是Xamarin Forms的新手.我不知道它的名字,但它现在起作用了.我想在那个蓝色栏上显示我的页面标题,而不是在导航栏上.我的页面标题必须显示在图片上的空白区域.我怎么能做到这一点?

enter image description here Xaml:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
        xmlns:local="clr-namespace:İdaServis.ViewModels"
        xmlns:renderers="clr-namespace:İdaServis.CustomRenderer"
        x:Class="İdaServis.View.PageName"
        Title="{Binding Title}"
        x:Name="Page"
        BackgroundColor="White">
 </ContentPage>

政务司司长:不,不,不.

public PageName()
{
    InitializeComponent();
    NavigationPage.SetHasNavigationBar(this, false);
}

推荐答案

我想在蓝色条上显示我的页面标题,而不是导航 wine 吧.

如果希望在蓝色条上显示页面标题,请将第二个参数NavigationPage.SetHasNavigationBar设置为true:

 public PageName()
{
    InitializeComponent();
    NavigationPage.SetHasNavigationBar(this, true);
}

然后,您可以通过为Page添加代码 Title="My Page"来设置页面标题.具体如下:

<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             Title="My Page"
             x:Class="MVVMApp.SecondPage">

   
</ContentPage>

当然,你也可以用TitleView来定制这个.

例如:

 <?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             Title="My Page"
             x:Class="MVVMApp.SecondPage">

    <NavigationPage.TitleView>
        <Label  Text="custom TitleView----->"/>
    </NavigationPage.TitleView>
    <ContentPage.Content>
        <StackLayout>
            <Label Text="Welcome to secoend page"
                VerticalOptions="CenterAndExpand" 
                HorizontalOptions="CenterAndExpand" />

        </StackLayout>
    </ContentPage.Content>
</ContentPage>

Android相关问答推荐

如何使禁用状态下的material 3按钮与启用状态下的 colored颜色 相同?

Android开发:主题排版不适用于按钮文本

在卡片上创建圆角底部边框

为什么Ionic-checkbox不总是刷新Android上的视图?

请求标头为空/无法通过拦截器获取

如何从Android 12的来电中获取电话号码?

Android布局渲染问题

如何禁用自动登录 google play games services android unity?

当 Jetpack Compose 中的第一个文本很长时,将省略号添加到第一个文本

是什么导致调用 Firebase 服务器?

在单元测试下断言协程未完成

java.lang.ExceptionInInitializerError -- 原因:java.lang.NullPointerException

为卡片的上半部分添加一个边框,用圆角半径组合

在 theme.xml 中使用 android:autoCompleteTextViewStyle

如何解决 compose 中material 图标的由于接收器类型不匹配,以下候选者都不适用

错误:构建 react-native 应用程序时包 com.facebook.react.bridge 不存在

您如何衡量条形图的 4 个类别?

在jetpack compose中将图像添加到脚手架顶部栏

如何从 Jetpack Compose 中的 Radio 组中获取价值

Android Studio (Kotlin):无法启动活动