-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with implicit vs explicit Shell Routing #17629
Comments
The question is - can the difference between implicit and explicit routing please be documented, including some words on the intended usage of each. Also: Is the limitation (exception on navigation) when using explicit registration an artificial one, or is it there for a reason? Can the community toolkit's DI registration methods be used in such a way that this exception does not happen? |
@PureWeen thoughts? |
This comment was marked as off-topic.
This comment was marked as off-topic.
I agree with this, Shell routing for this case seems to be broken. |
@PureWeen thoughts? |
For those looking into this. I'm running into this as well. It seems any explicit route registration is incompatible with constructor injection. It'll always throw with "no public parameterless constructor" for the routed page, instead of resolving that type from the service provider. Off-topic: This reproduction also showcases another issue, that I haven't found documented. I haven't managed to figure out how you can start a Shell based app on an explicit route, instead of an implicit shell item. My current approach is to register a blank content page as default shell item, and immediately call GoToAsync in OnAppearing, but this is at best an inelegant approach. |
Description
I have an issue with route registration in MAUI
Shell
.First of all, it is possible to define routes on different places, having a different effect. This different result is super confusing.
AppShell.xaml
using theRoute
attribute ofShellItem
s. This results in an object inShell.Current.Children
having anRoute
property with valueIMPL_{value of Route attribute in AppShell.xaml}
. This is an implicit route according to the logic in Routing.cs. It does not show up inRouting.s_routes
.Routing.RegisterRoute(route, typeof(TView))
, or using something likeAddSingletonWithShellRoute
from MAUI Community Toolkit (which callsRouting.RegisterRoute(route, typeof(TView))
under the hood). This does result in a route registered inRouting.s_routes
. I guess you could call this an explicit route then, although it is not called as such in the code.Another, even more annoying part is that
Shell.Current.GoToAsync("///LoadingPage")
on it without a problemShell.Current.GoToAsync("///LoadingPage")
throws an exception:This means that you cannot use
Routing.RegisterRoute(route, typeof(TView))
nor theAddSingletonWithShellRoute
convenience function to register routes if you want to do an absolute navigation.Documentation for this item is missing, and from the code it is not intuitive what to expect with what approach.
Steps to Reproduce
Link to public reproduction project repository
No response
Version with bug
8.0.0-rc.1.9171
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
Set the route directly in
AppShell.xaml
using theRoute
parameter of aShellItem
separately from the dependency injection registration.Relevant log output
No response
The text was updated successfully, but these errors were encountered: