Skip to content
0:00 / 0:00

#mvvm#sourcegenerators#communitytoolkit

MVVM Source Generators: Never Write MVVM Boilerplate Code Again!

James Montemagno

172K subscribers • 1 video on Hallway

YouTube

Intermediate. Assumes working knowledge.

81K views4 years ago3 recommendations

Programming languagesSoftware designC# and .NETDesign patternsSoftware architecture

James Montemagno explains how to use C# source generators in the .NET Community Toolkit to eliminate MVVM boilerplate code.

Imagine a world where you never had to raise another property changed event or write another IComand. Well, those days are here with the new .NET Community Toolkit, which introduces brand new source generators and helper classes to enable you to write super minimal code. I break down everything you need to know about the toolkit, how to use it, and why it is awesome! There have been several updates to the library and name changes for the properties, so check out github.com/CommunityToolkit/dotnet/releases/tag/v8.0.0 for changes Links: Source Code - github.com/jamesmontemagno/MVVMSourceGenerators Toolkit Blog - devblogs.microsoft.com/dotnet/announcing-the-dotnet-communit… Documentation - docs.microsoft.com/dotnet/communitytoolkit/mvvm/ Community Toolkit on GitHub - github.com/CommunityToolkit/dotnet Join this channel to get access to perks: youtube.com/channel/UCENTmbKaTphpWV2R2evVz2A/join 👕 Buy some swag! - jamesmontemagno.myspreadshop.com/ ☕️ Buy me a coffee - buymeacoffee.com/jamesmontemagno Follow: 👨‍💻 GitHub: github.com/jamesmontemagno 🦜 Twitter: twitter.com/jamesmontemagno 📄 Website: montemagno.com 📰 Newsletter: newsletter.montemagno.com/ Chapters: - Introduction to MVVM - Installing .NET Community Toolkit and INotifyPropertyChanged - ObservableObject and property changes - ObservableProperty source generator - ICommand source generator - Source Generator Wrap-up Disclaimer: This channel, videos, and streams are created in my spare time and are a product of me... James Montemagno! They are NOT officially affiliated or endorsed by Microsoft (my employer) in any way. Opinions and views are my own. What is on my hat? It is the CLE clothing logo because I am from Cleveland! Checkout their awesome CLE merch: cleclothingco.myshopify.com/ What is that art on my wall? It is an original piece from the French street artist Gregos of La Butte Montmartre: instagram.com/p/BceZ1oNHiQx/ My Setup: 💡 Nanoleaf Elements Lights - amzn.to/3umwJVW 🎙 Blue Spark Microphone - amzn.to/3qgtYkq 🎙 Blue Pop Filter - amzn.to/3jEWM3r 🤳 Rode Microphone Arm - amzn.to/2Z68AlE 🎧 Sony MDR7306 Headphones - amzn.to/372jxta 📲 Stream Deck - amzn.to/373Uk1n 📹 Elgato Cam Link - amzn.to/3a9eGbh 📷 GoPro Hero - amzn.to/374lm90 🖱 MX Master 2S Mouse - amzn.to/3d7J2gj ⌨️ Tecware Phantom Keyboard - amzn.to/3aUP4y9 #dotnet #mvvm #sourcegenerators

Why it's here

3 people recommend this

What people say. Recommended as a great introduction to using MVVM source generators to simplify WPF and .NET view models.

u/yumzin r/dotnet • Recommends

On “Command "responsibilities" in WPF MVVM pattern”

CommunityToolkit.Mvvm is the way to go IMO. Commands are as simple as: public partial class MyViewModel : ObservableObject { RelayCommand public void DoTheThing() { ... } } It autogenerates a `DoTheThingCommand` property which you can bind to in the view. EDIT: decent introduction video related to this: link to this video

u/laertezin r/dotnet • Recommends

On “MVVM framework for WPF”

link to this video

u/pHpositivoin r/dotnet • Recommends

On “What do you all think about MVVM toolkit, Microsoft's replacement for MVVMLight?”

Hey there! MVVM Toolkit's dev here. A bit late for this comment, but I did add source generators now, they're currently in preview if you grab `CommunityToolkit.Mvvm` version 8.0.0-Preview2 (or later). Planning on releasing a stable version soon. If you try them out, let us know how it goes! 😄 You can have an observable property generated with just this: ObservableProperty private string name; You can see a great intro made by James here. Cheers! 🙌