Home > Back-end >  ContentPage title doesn't work on .net maui android application
ContentPage title doesn't work on .net maui android application

Time:10-28

I try to create a title image for .net maui android application, but the title is not visible. Even if I change with a label, same result:

<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

how can I fix this?

CodePudding user response:

This potential issue is being fixed and tracked on this thread: https://github.com/dotnet/maui/issues/3877

I tested it using Visual Studio 17.3.5 and the label in the TitleView was shown in the contentpage.

Update:

In your AppShell.xaml.cs, change it like below:

MainPage = new NavigationPage(new MainPage());
  • Related