Extension methods to cleanly register Views and ViewModels in IServiceCollection #430
Closed
rjygraham
started this conversation in
New Feature Discussions
Replies: 2 comments 4 replies
-
Question for @brminnick @VladislavAntonyuk, are your 👍indicative that this discussion has received maintainer approval and ready to move feature proposal via converting this to an issue? |
Beta Was this translation helpful? Give feedback.
4 replies
-
Closed as per the Community Stand-up discussion here: https://youtu.be/N9wMcBP4jtg?t=2889 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'd like to propose adding the following extension methods to CommunityToolkit.Maui which cleanly registers Views and ViewModels in the MAUI IServiceCollection. I've also added extension methods to optionally register Shell routes for pages not explicitly added to AppShell.xaml:
Below is an example of the extension methods in use:
In addition to registering the Views and ViewModels in MAUI IoC container, the extension methods also uses generic type constraints for ViewModels to ensure they implement
INotifyPropertyChanged
.This can be helpful in tightening the inner loop by failing builds when a developer adds a new Page and ViewModel but forgets to inherit from
ObservableObject
or another class implementingINotifyPropertyChanged
, use the[INotifyPropertyChanged]
source generator attribute, or implementINotifyPropertyChanged
directly.Beta Was this translation helpful? Give feedback.
All reactions