Having a bit of a weird one with Shell navigation and the timing of ApplyQueryAttributes
relative to other page lifecycle events.
My app navigates to a MainPage with a menu that then navigates through other pages in the app until it reaches a page that requires a Flyout Menu.
So
MainPage > PageA > PageB > PageWithFlyoutMenu
I’m performing the navigation as follows
MainPage to PageA: await Shell.Current.GoToAsync($"PageA", true);
Lifecycle event order:
Constructor
> ApplyQueryAttributes
> OnAppearing
> OnNavigatedTo
PageA to PageB: await Shell.Current.GoToAsync($"PageB");
Lifecycle event order:
Constructor
> ApplyQueryAttributes
> OnAppearing
> OnNavigatedTo
PageB to PageWithFlyoutMenu: await Shell.Current.GoToAsync($"///PageWithFlyoutMenu-1");
Lifecycle event order:
Constructor
> OnAppearing
> OnNavigatedTo
> ApplyQueryAttributes
The issue here is that ApplyQueryAttributes
is the last to be invoked.
AppShell is as follows:
<Shell
x:Class="****.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:****.Views"
xmlns:localDetail="clr-namespace:****.Views.DetailPages"
Title="****">
<ShellContent
Title="MainPage"
ContentTemplate="{DataTemplate local:MainPage}"
FlyoutItemIsVisible="False"
Route="MainPage"
Shell.FlyoutItemIsVisible="False" />
<ShellContent
Title="PageWithFlyoutMenu-1"
ContentTemplate="{DataTemplate localDetail:PageWithFlyoutMenu-1}"
Route="PageWithFlyoutMenu-1" />
<ShellContent
Title="PageWithFlyoutMenu-2"
ContentTemplate="{DataTemplate localDetail:PageWithFlyoutMenu-2}"
Route="PageWithFlyoutMenu-2" />
</Shell>
And I have the following routes registered:
Routing.RegisterRoute("PageA", typeof(PageA));
Routing.RegisterRoute("PageB", typeof(PageB));
Can anyone shed any light on why this would be?
Thanks in advance