The Next Generation MVVM library – Say Goodbye to the Boilerplate

Implementing the Model-View-ViewModel pattern (MVVM) in XAML applications like WPF, WinUI, Uno Platform or .NET MAUI often means that you have to write a lot of boilerplate code: Creating properties that raise the PropertyChanged event, creating command properties to execute methods, injecting services and store them in fields to use them and so on and so on.

Wouldn’t it be great if all that boilerplate code could get generated for you on the fly while you’re creating your ViewModel classes? Exactly this is what MvvmGen does for you: You can focus on your business logic, and MvvmGen will generate the boilerplate for you while you’re typing. MvvmGen is a modern MVVM library that is built with Roslyn-powered C# source generators and that contains everything you need to build a XAML application with the MVVM pattern:

  • A ViewModelBase class
  • An ICommand implementation
  • An EventAggregator to communicate between ViewModels

But the most important part of MvvmGen are its attributes that you use on your classes to generate the boilerplate.

Learn more about MvvmGen in this introduction blog post, and find sample applications in this GitHub repository.