NavigationPage Title Not Changing in .NET8 MAUI App

103 Views Asked by At

NavigationPage Title is not changing in Windows and Android platforms when we navigate from one activity to another activity through hamburger menu and title is not changing when switching between pages also in MAUI application targeting .NET8.

But, it works fine in .NET7 in all platforms.

<FlyoutPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
        xmlns:local="clr-namespace:FlyoutPageSample"
        x:Class="FlyoutPageSample.AppFlyout"
        FlyoutLayoutBehavior="Popover"
        >
<FlyoutPage.Flyout>
    <local:FlyoutMenuPage x:Name="flyoutPage" />
</FlyoutPage.Flyout>
<FlyoutPage.Detail>
    <NavigationPage>
        <x:Arguments>
            <local:MainPage />
        </x:Arguments>
    </NavigationPage>
</FlyoutPage.Detail>
flyoutPage.collectionView.SelectionChanged += OnSelectionChanged;

void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
        var item = e.CurrentSelection.FirstOrDefault() as FlyoutPageItem;
        if (item != null)
        {
            Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType));
            //IsPresented = false;
        }
}

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:FlyoutPageSample"
             x:Class="FlyoutPageSample.FlyoutMenuPage"
             Title="FlyoutMenuPage">
    <CollectionView x:Name="collectionView"
                    x:FieldModifier="public"
                    SelectionMode="Single">
        <CollectionView.ItemsSource>
            <x:Array Type="{x:Type local:FlyoutPageItem}">
                <local:FlyoutPageItem Title="Contacts"
                                      IconSource="contacts.png"
                                      TargetType="{x:Type local:MainPage}" />
                <local:FlyoutPageItem Title="TodoList"
                                      IconSource="todo.png"
                                      TargetType="{x:Type local:MainPage2}" />
                <local:FlyoutPageItem Title="Reminders"
                                      IconSource="reminders.png"
                                      TargetType="{x:Type local:MainPage3}" />
            </x:Array>
        </CollectionView.ItemsSource>
        <CollectionView.ItemTemplate>
            <DataTemplate>
                <Grid Padding="5,10">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="30"/>
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Image Source="{Binding IconSource}" />
                    <Label Grid.Column="1"
                           Margin="20,0"
                           Text="{Binding Title}"
                           FontSize="20"
                           FontAttributes="Bold"
                           VerticalOptions="Center" />
                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>
</ContentPage>
0

There are 0 best solutions below