You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be cool to have the ability to check whether a certain route has already been registered.
In my scenario I am doing route registration automatically via a navigation service and extended ContentPage.
However, due to the current API and behavior of .NET MAUI, there is a scenario in which the code attempts to register the same route twice.
I don't really want to catch exceptions and check for string equality since it would also swallow developer's mistakes.
I'd rather have an API to check for a specific route whether it has already been registered or not before calling Routing.RegisterRoute.
Alternatively Routing.RegisterRoute could have a parameter to set whether it should throw on duplicate registration attempt or not.
I am using Shell with Flyout and want a specific page to be created on app startup.
However, I have an extended ContentPage where I am passing a ViewModel instance as constructor parameter to be able to automatically resolve it using the IServiceProvider during Shell navigation.
To still be able to pre-create the page during app startup, I am now setting the BindingContext via XAML and in OnBindingContextChanged registering the route to the page.
The OnBindingContextChanged, however, does get called more than once and therefor can throw an exception on attempting to register the route.
This discussion was converted from issue #20984 on March 04, 2024 15:31.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Description
It would be cool to have the ability to check whether a certain route has already been registered.
In my scenario I am doing route registration automatically via a navigation service and extended
ContentPage
.However, due to the current API and behavior of .NET MAUI, there is a scenario in which the code attempts to register the same route twice.
I don't really want to catch exceptions and check for string equality since it would also swallow developer's mistakes.
I'd rather have an API to check for a specific route whether it has already been registered or not before calling
Routing.RegisterRoute
.Alternatively
Routing.RegisterRoute
could have a parameter to set whether it should throw on duplicate registration attempt or not.Public API Changes
or
Intended Use-Case
I am using
Shell
withFlyout
and want a specific page to be created on app startup.However, I have an extended
ContentPage
where I am passing a ViewModel instance as constructor parameter to be able to automatically resolve it using theIServiceProvider
during Shell navigation.To still be able to pre-create the page during app startup, I am now setting the
BindingContext
via XAML and inOnBindingContextChanged
registering the route to the page.The
OnBindingContextChanged
, however, does get called more than once and therefor can throw an exception on attempting to register the route.Beta Was this translation helpful? Give feedback.
All reactions