Replies: 1 comment 3 replies
-
This sounds like a good improvement to me and a step in the right direction, however I'm not sure how useful it would be without also taking other parameters. Full disclaimer: I'm still generally just as confused by the complexity of combining MVVM with navigation now as I was 10+ years ago. Seemingly simple things like navigating from one part of an app another (and passing a Model object) from within a Command delegate requires a tonne of plumbing if you don't wish to pollute the VM with references to Pages. Out-of-the-box navigation has always felt like something that only survives for trivial or demo apps, whereas custom navigation services that handle VM to VM navigation for example feel too heavy for moderately sized apps. |
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.
-
Currently the INavigation interface is as it was in Xamarin Forms, that is to say the navigation methods like PushAsync take an instance of the page they are trying to navigate to. While this is fine as far as it goes, pretty much every Mvvm framework that works with Xamarin Forms had to deal with trying to make this dependency injection friendly.
The current design of the method methods begs the question of how do those pages being navigated to get created. Does whatever calls to navigate also need to have all pages that it may navigate to proactively injected in? Do they need to use the IServiceProvider in their code as a service locator to create the pages for them before navigating?
What I believe would be ideal if methods like PushAsync took a page type as a parameter. The Navigation provider would then be responsible for creating the page from dependency injection. It would be a bonus feature if it was configurable, either globally or on a per page basis, if new pages created will be within a new scope.
Beta Was this translation helpful? Give feedback.
All reactions