Replies: 2 comments
-
@brminnick @jamesmontemagno wondering if you can help us understand the mapping here from Xamarin/MAUI to the base .NET pattern. FYI @Sergio0694 @scastria could you provide a snippet of your XAML and code-behind too in order to help us understand how things are constructed in your app and being used? (Also maybe an older similar example of how you did it before in Xamarin?) |
Beta Was this translation helpful? Give feedback.
-
The code-behind should not be used as the ViewModel, because it is part of the View. The XAML you write is a By putting your business logic in the code-behind, you are not adhering to the MVVM architecture. Rather, you are more closely implementing the MVC architecture. |
Beta Was this translation helpful? Give feedback.
-
With Xamarin.Forms, I am used to using the code behind page class as the view model since it already implements INotifyPropertyChanged. Therefore, I would just set the BindingContext = this and life was good. I attempted to do the same thing with MAUI and with these new code generators. Unfortunately, it doesn't work. It looks like the implementation of INotifyPropertyChanged is slightly different between MAUI Pages and the CommunityToolkit. The end result is: cannot convert from 'System.ComponentModel.PropertyChangedEventArgs' to 'string' build errors. Can this be fixed? I find using the Page class as the ViewModel very convenient as that means one less class to deal with. But perhaps this is bad practice?
Beta Was this translation helpful? Give feedback.
All reactions