BurkusCat / Burkus.Mvvm.Maui

A simple MVVM framework for .NET MAUI. It provides: navigation, lifecycle events, parameter passing, native dialog abstractions, and testability.
MIT License
23 stars 5 forks source link

[Feature] Map navigation parameters to properties on navigation #16

Open BurkusCat opened 9 months ago

BurkusCat commented 9 months ago

Is your feature request related to a problem? Please describe. Having to set basic properties in the OnNavigatedTo lifecycle method can be repetitive. It would be good if there was a way to automatically set properties with a similar name.

Describe the solution you'd like Something similar to query properties in Shell might be nice: https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/shell/navigation#process-navigation-data-using-query-property-attributes. This allows you to map parameter names to a navigation parameter key which may be different.

Describe alternatives you've considered OnNavigatedTo provides an advance way to set parameters but may get repetitive. This method of parameter passing may mean you don't need to implement the INavigatedEvents interface on some viewmodels.

Proposed APIs

// as an annotation above a viewmodel you can do as many of the below as you wish:
[MapNavigationParameter(nameof(TestParam), "test_param")]

Additional context N/A

BurkusCat commented 1 month ago

I've split this out into #61