I made a demo maui app and I have found that this line of code:
AppShell.Current.GoToAsync("//HomeMenu");
works fine when the app is run to an Android local device but does not work when the app is running as a Windows app.
I have registered the routes in AppShell.cs like this:
Routing.RegisterRoute(nameof(HomeMenu), typeof(HomeMenu));
Routing.RegisterRoute(nameof(But2Page), typeof(But2Page));
Routing.RegisterRoute(nameof(But2Sub), typeof(But2Sub));
Routing.RegisterRoute(nameof(But2SubSub), typeof(But2SubSub));
Here is a representation of the ContentPages I am displaying for this use case:
Home Menu
- Button2 Page
□ Button 2 Sub Page
- Button 2 Sub Sub Page
Here are the commands that the code executes to walk down that hierarchy
AppShell.Current.GoToAsync("But2Page");
AppShell.Current.GoToAsync("But2Sub");
AppShell.Current.GoToAsync("But2SubSub");
That all works fine on both platforms. On the But2SubSub page the code does the following:
AppShell.Current.GoToAsync("//HomeMenu");
On Android the app displays the Home Menu page. On Windows the value at the top of the page displays "Home Menu" but the page content remains the But2SubSub content:
NOTE: I have not declared any routes at all in the AppShell.xaml file. It simply has this:
<ShellContent
Title="HomeMenu"
ContentTemplate="{DataTemplate local:HomeMenu}"
Route="HomeMenu" />
How can I make the last GoToAsync method work correctly in the Windows app?
Thanks.