Cannot create my custom navigation service wrapper #2037
-
Hello, So I defined my custom navigation service in this way:
then I've registered it as
and finally in the ViewModel I've injected it instead of INavigator. But when I try to navigate to the second page, I get the error "System.ArgumentNullException: Value cannot be null. (Parameter 'provider') What am I doing wrong? I saw in Uno.Extensions' code that INavigator is registered in several points as 'AddScopedInstance' instead of singleton. Can the issue depends from that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@ste8 I think if you register the MyNavigationService using AddScopedInstance this should address this issue. Scoping is used as a way of keeping multiple navigation stacks independent from each other. For example if you have a Frame that has a navigation stack (similar to the Frame's backstack) but then within any of those pages you might have a TabBar which has it's own navigation stack. We create a new scope for each navigation region, so you'll get a different INavigator for each navigation region. INavigators aren't related to each other, but do map to a navigation region, and navigation regions are typically part of a hierarchy defined by the application flow. |
Beta Was this translation helpful? Give feedback.
@ste8 I think if you register the MyNavigationService using AddScopedInstance this should address this issue.
Scoping is used as a way of keeping multiple navigation stacks independent from each other. For example if you have a Frame that has a navigation stack (similar to the Frame's backstack) but then within any of those pages you might have a TabBar which has it's own navigation stack.
We create a new scope for each navigation region, so you'll get a different INavigator for each navigation region. INavigators aren't related to each other, but do map to a navigation region, and navigation regions are typically part of a hierarchy defined by the application flow.