2

In Xamarin, I frequently used <NavigationPage.TitleView> to customize the navigation title bar in my views. Now that I am working in MAUI, this tag seems to have no effect on a ShellItem view.

Here is AppShell.xaml:

<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="MyApp.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:localize="clr-namespace:FleetHDMobile.Resources.Strings"
    xmlns:local="clr-namespace:FleetHDMobile.Views"
    Shell.FlyoutBehavior="Disabled">

    <ShellItem Route="MainPage">
        <ShellContent 
            Title="MainPage"
            ContentTemplate="{DataTemplate local:MainPage}"
            />
    </ShellItem> . . .

Here is MainPage.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:localize="clr-namespace:FleetHDMobile.Resources.Strings"
             Shell.FlyoutBehavior="Flyout"
             x:Class="FleetHDMobile.Views.MainPage">
    <NavigationPage.TitleView>
        <Label
            Text="XXX"
            HeightRequest="44"
            WidthRequest="300" />
    </NavigationPage.TitleView>

    <ScrollView>

I have tried making MainPage a tab in the tabbar, but that didn't customize the title view either.

The <NavigationPage.TitleView> tag has no effect on the rendered view. I would like to put small logo icons in the title bar, but cannot figure out how to do so.

Chuck Krutsinger
  • 2,830
  • 4
  • 28
  • 50
  • Does this answer your question? [How can I customize the Title in a .NET MAUI Flyout Shell app?](https://stackoverflow.com/questions/75692967/how-can-i-customize-the-title-in-a-net-maui-flyout-shell-app) – Julian Mar 26 '23 at 07:40

3 Answers3

1

There are some known issues about this problem.

You can follow up them here:

https://github.com/dotnet/maui/issues/9269

https://github.com/dotnet/maui/issues/9687

Thanks for your support and feedback.

Jessie Zhang -MSFT
  • 9,830
  • 1
  • 7
  • 19
1

You must use <Shell.TitleView> rather than <NavigationPage.TitleView> in a MAUI app that uses Shell.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
JEstes
  • 26
  • 1
0

Did you try doing it through the ViewModel or the .cs of your View ?

Such as for MainPage.xaml.cs or MainPageViewModel.cs

public class MainPageViewModel
{
    public MainPageViewModel
    {
        Title = “”; // or this.Title = “”;
    }
}
Jimmy
  • 105
  • 15