(The forum does not allow me to paste links, so I apologize for the inconvenience of neutered links.)
The Prism library has a Prism-Samples-Forms[1] repo with a HamburgerMenu project. The HamburgerMenu sample has some login stuff, then lets you navigate between {ViewA,ViewB,ViewC} via buttons on a master page. Even within the simple navigation of the HamburgerMenu sample, I'm confused about what is going on.
I've modified the HamburgerMenu sample to show the user more info about the navigation stack and hosted the code at this HamburgerMenuMystery[2] repo.
One rather general question is: What exactly happens when you do a NavigationService.NavigateAsync("NavigationPage/SomeContentPage")
? It causes you to navigate to SomeContentPage that is wrapped in a NavigationPage (so you get navigation icon, title, and toolbar items shown), right? I see this sort of "NavigationPage/SomeContentPage" a lot in Prism apps, but I've never seen an explanation of what it does nor guidelines about when to do/not-do it.
Some very specific questions about HamburgerMenuMystery behavior...
App.xaml.cs navigates to "/Index/Navigation/ViewA?message=InitialNav" ("Index" is an alias for MainPage, a MasterDetailPage), so when you start the app you are navigated to ViewA, which displays to the user Prism's GetNavigationUriPath and Xamarin's NavigationStack.
In ViewAViewModel, Prism's _navigationService.GetNavigationUriPath() returns "/Navigation/ViewA"; why is "/Index" absent?
In ViewA.xaml.cs, Xamarin's Navigation.NavigationStack is "/ViewA" (and the ModalStack is empty); why is "/Index" absent? Why does the Xamarin NavigationStack differ from Prism's GetNavigationUriPath?
(see first picture in repo README.md [3])
If you then click the hamburger icon so you get the MainPage master page, and click the "N/A" button so MainPageViewModel does a
_navigationService.NavigateAsync("Navigation/ViewA?message=NA")
...- Prism's GetNavigationUriPath returns "/Index/Navigation/ViewA"; why does "Index" appear now and not before?
(see second picture in repo README.md [3])
If you then click the hamburger icon and then click the "N/B" button, so the MainPageViewModel does a
_navigationService.NavigateAsync("Navigation/ViewB?message=NB")
...- Prism's GetNavigationUriPath returns "/Index/Navigation/ViewA/Navigation?useModalNavigation=true/ViewB"; why the
useModalNavigation=true
, especially considering that MainPageViewModel usesuseModalNavigation: false
when calling NavigateAsync? - Xamarin's Navigation.NavigationStack is simply "/ViewB" and ModalStack is again empty; why are these stacks so different from what GetNavigationUriPath indicates?
- Prism's GetNavigationUriPath returns "/Index/Navigation/ViewA/Navigation?useModalNavigation=true/ViewB"; why the
(see third picture in repo README.md [3])
[1] Prism-Samples-Forms, github.com/PrismLibrary/Prism-Samples-Forms
[2] HamburgerMenuMystery, github.com/jmegner/HamburgerMenuMystery
[3] HamburgerMenuMystery README.md, github.com/jmegner/HamburgerMenuMystery#hamburger-menu-mystery