I am having this problem where my navigation just seems to stop working in my Maui app. I generally use:
Shell.Current.GoToAsync(route);
to go between pages.
But every now and then it just stops working. Most of the time there are no error messages or any exceptions being thrown, but sometimes I do get strange exceptions.
Also, I have one page in particular which I get stuck on every time I navigate to it. I just can't seem to navigate anywhere from it. I tried using ".." as the route but that doesn't work either.
I just have the feeling I am missing something.
My app is probably a bit too complex to upload a working example, but the shell looks like below. The page I have trouble with is the SelectorPage. I navigate to it using:
Shell.Current.GoToAsync("SelectorPage");
then on that page I try to navigate back using these:
Shell.Current.GoToAsync("LoginPage");
Shell.Current.GoToAsync("..");
but nothing happens. Putting a breakpoint on the code shows me the code is executed.
Any thoughts?
<?xml version="1.0" encoding="UTF-8" ?>
<Shell x:Class="xxx.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
FlyoutHeaderBehavior="CollapseOnScroll"
FlyoutWidth="300" >
<!-- Initial load goes to LoadingPage, which then determines route to take -->
<ShellItem FlyoutItemIsVisible="False" x:Name="LoadingPageShellItem">
<ShellContent ContentTemplate="{DataTemplate views:LoadingPage}" Route="LoadingPage" />
</ShellItem>
<FlyoutItem Title="Home" FlyoutIcon="homemenu.png" x:Name="MainPageShellItem">
<ShellContent Title="Home" Icon="home.png" ContentTemplate="{DataTemplate views:HomeMainPage}" Route="HomeMainPage"/>
<ShellContent Title="Notifications" Icon="alert.png" ContentTemplate="{DataTemplate views:NotificationsPage}" Route="NotificationsPage" />
<!--Split tab for message page-->
<Tab Title="Chat" Icon="msg.png">
<ShellContent Title="Messages" ContentTemplate="{DataTemplate views:MessagesPage}" Route="MessagesPage" />
<ShellContent Title="Message Board" ContentTemplate="{DataTemplate views:MessageBoardPage}" Route="MessageBoardPage" />
</Tab>
</FlyoutItem>
<FlyoutItem Title="Login" FlyoutIcon="logoff.png" x:Name="LoginPageShellItem" FlyoutItemIsVisible="False">
<ShellContent ContentTemplate="{DataTemplate views:LoginPage}" Route="LoginPage" />
</FlyoutItem>
</Shell>
EDIT: I have a working example here if anyone cares to have a look: https://pdscode.com.au/wp-content/uploads/2023/02/MauiApp3.zip
I can't reproduce the exact problem in this but I do see glitches. The app has 16 'wizard' pages. After that you go to a login page which takes you to the main app. From the burger menu you can choose Reset to go back to the start. I notice that stops working after you go through a couple of times. However, hopefully someone will be able to look and tell me if I have done something terribly wrong!
Thanks