You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off I really like the idea of using a source generator to deal with the monotony of writing view models. In order to get somewhat familiar with one I used generating the required things for view models as I'm sure most people have.
With that being said the current design of having to inherit from ObservableObject and including ObservableProperty on backing fields feels too verbose. Would it be possible to make it more convention based? Here is what a view model could look like.
I REALLY like your idea of using attributes to generate the commands so in my example I combined my approach to properties to your approach with commands. Idea was you mark the class partial and as long as you have ViewModel at the end of the class name...well that is a view model so let's do our magic. Backing fields for properties are prefixed with p_ and then for computed fields I just say what fields it is computed from so I know what properties I need to add the NotifyPropertyChanged invocation at.
Is this something that is worth while and possible? Maybe you could support both ways since you already went down the one path with attributes?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
First off I really like the idea of using a source generator to deal with the monotony of writing view models. In order to get somewhat familiar with one I used generating the required things for view models as I'm sure most people have.
With that being said the current design of having to inherit from
ObservableObject
and includingObservableProperty
on backing fields feels too verbose. Would it be possible to make it more convention based? Here is what a view model could look like.I
REALLY
like your idea of using attributes to generate the commands so in my example I combined my approach to properties to your approach with commands. Idea was you mark the classpartial
and as long as you haveViewModel
at the end of the class name...well that is a view model so let's do our magic. Backing fields for properties are prefixed withp_
and then for computed fields I just say what fields it is computed from so I know what properties I need to add theNotifyPropertyChanged
invocation at.Is this something that is worth while and possible? Maybe you could support both ways since you already went down the one path with attributes?
Beta Was this translation helpful? Give feedback.
All reactions