【问题标题】:ContentPage title doesn't work on .NET MAUI Android applicationContentPage 标题在 .net maui android 应用程序上不起作用
【发布时间】:2022-11-10 10:28:21
【问题描述】:

我尝试为 .net maui android 应用程序创建标题图像,但标题不可见。即使我使用标签进行更改,结果也相同:

<ContentPage  xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="ChapsPizza.Views.MainPage"
         xmlns:vm="clr-namespace:ChapsPizza.ViewModels"
         Title="Test">

<NavigationPage.TitleView>
    <Label Text="Test" TextColor="Black"/>
    <!--<Image Source="logo.png" Background="Orange"
        VerticalOptions="CenterAndExpand" 
        HorizontalOptions="CenterAndExpand"
        HeightRequest="40" WidthRequest="40"/>-->
</NavigationPage.TitleView>

<ContentPage.BindingContext>
    <vm:MainPageViewModel/>
</ContentPage.BindingContext>

https://imgur.com/a/AitiWWf

我怎样才能解决这个问题?

【问题讨论】:

  • 你如何导航到这个页面你能告诉我吗
  • 它是主页,如果我在 TitleView 之外创建另一个标签,我会看到它
  • 我可以知道你的 Visual Studio 版本是什么吗?您需要至少更新到17.3.5

标签: .net xaml title maui


【解决方案1】:

这个潜在的问题正在这个线程上得到修复和跟踪:https://github.com/dotnet/maui/issues/3877

我使用Visual Studio 17.3.5 对其进行了测试,TitleView 中的label 显示在内容页面中。

更新:

在您的 AppShell.xaml.cs 中,将其更改如下:

MainPage = new NavigationPage(new MainPage());

【讨论】:

猜你喜欢
  • 2023-02-25
  • 2022-08-23
  • 2022-12-03
  • 2022-06-15
  • 2022-10-13
  • 1970-01-01
  • 2015-03-01
  • 2022-10-05
  • 2022-10-23
相关资源
最近更新 更多