Skip to content

ViewModel naviagtion. Do we just use the ViewModel name as THE key? #3135

Answered by dansiegel
munkii asked this question in General
Discussion options

You must be logged in to vote

As @brianlagunas indicated Prism doesn't directly support this. Navigation is by design key based. Prism uses certain defaults which results in using the View type name if no navigation key is provided. For example by default if you had:

containerRegistry.RegisterForNavigation<LoginPage, LoginViewModel>();

The navigation key would be LoginPage. However if you specified a key like:

containerRegistry.RegisterForNavigation<LoginPage, LoginViewModel("Login");

Then the navigation key would be Login. However with Prism.Maui's Page navigation specifically you can use the NavigationBuilder to achieve strongly typed ViewModel based navigation like:

var result = await navigationService.CreateBuilder()

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@munkii
Comment options

Answer selected by munkii
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants