This is the completed code sample shown during the "MVVM Building Blocks for WinUI and WPF Development" .NET Conf 2024 talk:
The majority of this code was added live during the talk, so you can follow-along! Just copy the modified starting XAML contents in MVVMNetConfApp.Wpf/MainWindow.xaml to a new WPF app to get started!
The talk and code go over the benefits of the MVVM pattern, how to simplify implementing it with the MVVM Toolkit, and how the MVVM pattern can be used to architecture your application to:
- Separate concerns
- Re-use code
- Abstract platform behavior
- Make testing easier
- Separate design and development
-
This project was constructed from file->new templates, starting with WPF.
-
We then added some preliminary XAML in the initial commit to the MainWindow.xaml file.
-
We added the new .NET 9 theming support for WPF.
-
We add a new class library for ViewModels and start using the MVVM Toolkit source generators.
-
We show how to add a unit test project and use .NET unit testing directly.
-
We then show how to use the same XAML in WinUI, leverage our existing abstracted code with the MVVM pattern, and then update to use x:Bind for better performance at compile time and to be able to leverage Native AOT support (outside the scope of this talk/demo).
Learn more about Windows native development here
For the latest information on choosing between WPF and WinUI, see the Ignite talk "BRK305: Navigating Win32 App Development with WPF and WinUI":
For the latest with WinUI, see the "What's new in WinUI and Windows App SDK 1.6":
For the latest with WPF, see "Empowering WPF Developers - WPF in .NET 9":



