Shell navigation for dynamic hierarchical content #31953
-
How exactly does one do shell navigation for dynamic hierarchical content? Is there an example somewhere? The docs are lacking to say the least. As a classic example, let's say you have a file system (tree) you want to browse using 3 pages:
Shell navigation from root to listing, and from listing to details are both straightforward. But how does one navigate from listing to listing with a different directory object? (and I mean an arbitrary object! NOT a string query paramemeter - aka using IDictionary<string, object> or ShellNavigationQueryParameters only and never the query string variants) Perhaps I'm doing something wrong, but using GoToAsync to the same route for listing while already on listing with different data appears to "work" in the forward direction, but the back stack (via the toolbar button) is completely fubar - going back reloads with the current query parameters instead of the previous and pressing it again does nothing, while the hardware back goes back to root. It seems totally broken - ripe for a bug report, but I wanted to check here first in case I'm missing something, plus it's not like anything ever gets fixed under a year or two anyway so no rush in filing another shell bug for which even the maintainers call "half-baked" that will just get effectively ignored, but I digress... So while it would probably be possible hook the back button and implement the listing<->listing navigation stack within the listing page instead of using GoToAsync, that seems to defeat the purpose of using the shell - I mean the shell has its own nav stack and there should be a way to leverage it, but is there? and what is that way if it exists? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
As you said, finding a perfect solution is difficult, but with different workarounds you can achieve your goal. From your description, the most problematic part appears to be navigating back. You can take a look at this documenation for Back button behaviour. The Android have hardware back button, which I think it is mentioned here and how to add an event handler to that. You can combine a ToolbarItem bound to an ICommand, configure OnBackButtonPressed to reuse the same command, and use ShellNavigationQueryParameters to send parameters back to the Listing page. |
Beta Was this translation helpful? Give feedback.
-
@rokmeglic71 thanks for the reply. The links you provided will certainly help with taking control of navigation if I need to implement my own sub-nav stack within a given page. That would probably be best from a memory and performance standpoint if I don't care about losing the page transitions or actually want to enhance what the drill down transition/animation looks like. For now though, I have managed to make navigation work in the contrived listing<->listing example without said extra effort. For anyone else confused by shell nav to the same routes more than once in the stack:
If you run into problems with one platform, try another - error checking/reporting is hit or miss and if you are doing something wrong, another platform might give clues as to what's wrong. |
Beta Was this translation helpful? Give feedback.
@rokmeglic71 thanks for the reply. The links you provided will certainly help with taking control of navigation if I need to implement my own sub-nav stack within a given page. That would probably be best from a memory and performance standpoint if I don't care about losing the page transitions or actually want to enhance what the drill down transition/animation looks like. For now though, I have managed to make navigation work in the contrived listing<->listing example without said extra effort.
For anyone else confused by shell nav to the same routes more than once in the stack: