Understanding implicit vs explicit shell route registration #17628
Replies: 3 comments
-
|
One workaround would be to add a ShellItem with Route="LandingPage" to your AppShell.xaml. Then you can invoke |
Beta Was this translation helpful? Give feedback.
-
|
@PureWeen Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
Let's assume you want to have two top-level pages Register Register.Route(nameof(LandingPage), typeof(LandingPage));
Register.Route(nameof(SecondPage), typeof(SecondPage));In the constructor of MainPage, navigate to the LandingPage, e.g. public partial class MainPage : ContentPage
{
public MainPage()
{
Dispatcher.Dispatch(async() => await Shell.Current.GoToAsync(nameof(LandingPage)); // route will become //MainPage/LandingPage
}
}Then from the Also, you can make both <ContentPage ... >
<Shell.BackButtonBehavior>
<BackButtonBehavior IsVisible="False" IsEnabled="False" />
</Shell.BackButtonBehavior>
<!-- ... -->
</ContentPage>Reference: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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.xamlusing theRouteparameter ofShellItems. This results in an object inShell.Current.Childrenhaving anRouteproperty with valueIMPL_{value of Route parameter 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 likeAddSingletonWithShellRoutefrom 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 theAddSingletonWithShellRouteconvenience 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
Beta Was this translation helpful? Give feedback.
All reactions