Shell Navigation with parameters in a type-safe contract #18968
Unanswered
TrueMoniker
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am converting a simple app from Xamarin to Maui, and will be converting a large enterprise application in the future.
While I understand how to pass parameters, I feel the contract for the parameters is not type-safe. Whether using IQueryableAttribute or multiple use object-based navigation data, if I change one of the expected parameters and forget to update all the calls to that view, nothing throws an exception.
As a solution, I have created a class that a view model can inherit to provide a type-safe contract. In my own code, I've extended it to accept up to 3 parameters using polymorphism
How it works:
-The view model that receives the parameter has a static method
CreateParameters
that can be called to generate the parameters in a dictionary, then the app navigation works as normal using the multiple use object-based navigation dataExample:
Pros:
Cons
CreateParameter
method, but then navigate to the view. This is starting to couple the two together, though not any more than the regular navigation with parameters does.Beta Was this translation helpful? Give feedback.
All reactions