Allow ObservableProperty to be used in classes implementing INotifyPropertyChanged #659
Replies: 2 comments
-
Just a side note: When you place all commands and properties in your code-behind, then you're skipping the ViewModels and thus, you're not doing MVVM, because you're tight-coupling your business logic to the view. The name CommunityToolkit.Mvvm already suggests, that this is targeted at the Model-View-ViewModel pattern. I do agree that using Source Generators in code-behind files would be a valuable addition, I just wanted to point that out. From a technical point of view, I think the problem with ContentViews and MVVM Source Generators is due to inheritance and partial classes. It should technically be possible to implement this, but the ContentViews should remain independent from MVVM architecture, meaning that concerns shouldn't be mixed. Therefore, the same Source Generators shouldn't be used for this. |
Beta Was this translation helpful? Give feedback.
-
Apart from this not following the MVVM approach, the technical request is a duplicate of #336 |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, suppose I liked my view models to be close to their view. So close, in fact, that I'd define my commands and properties in the code behind file (easier to understand, less files to manage).
Unfortunately, this is not allowed. The error MVVMTK0002 is shown.
What's exactly the problem here? Since a
ContentView
is already implementingINotifyPropertyChanged
, the source generator should just add the missing parts.Beta Was this translation helpful? Give feedback.
All reactions