-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learn WinUI 3
By :

It’s time to update the project to move the event handling code to MainViewModel
. By the end of this section, you will have removed all the code that was added to the MainWindow.xaml.cs file, except for the ViewModel
property. This will be great for the separation of concerns, as well as for the maintainability and testability of the project.
We could use the same process of wiring up events with the Add button’s Click
event and connect it to a method on the MainViewModel
class. There are two problems with this approach:
Let’s take another route. The MVVM pattern has the concept of Commands to handle events. Instead of adding a handler to the event of our view element, we will bind that event to a property on the view model. The Command
properties...