.NET Community Toolkit
ฝัง
- เผยแพร่เมื่อ 5 ส.ค. 2024
- James Montemagno introduces the .NET Community Toolkit and shows examples of how it greatly simplifies your MVVM code including WPF, .NET MAUI, Xamarin.Forms, and more.
Chapters
00:00 - Introduction and an overview of the .NET Community Toolkit
04:55 - Community Toolkit GitHub page
05:00 - Review of demo starting code
08:30 - Install the CommunityToolkit.Mvvm NuGet package
10:00 - Using the INotifyProperyChanged attribute
12:30 - Inheriting from ObservableObject
13:20 - Using the Using the AlsoNotifyChangeFor attribute
17:10 - Using the ICommand attribute
20:45 - Using the latest C# features in a .NET Framework app
23:10 - Wrap-up
Recommended resources:
Introducing the .NET Community Toolkit (On .NET show episode) - docs.microsoft.com/en-us/show...
Community Toolkit GitHub page - github.com/communitytoolkit
.NET MAUI Workshop - github.com/dotnet-presentatio...
MVVM Source Generators demo code - github.com/jamesmontemagno/MV...
James on TH-cam: / jamesmontemagno
#dotnet #visualstudio #mvvm - วิทยาศาสตร์และเทคโนโลยี
love Robert's office , lovely doors . Very cozy place .
Great video, James! Thank you for doing this sample in WPF! There is a ton of this kind of application! Keep going!
I'm just about to start a new WPF project and you guys have just saved me a ton on work! Thanks!
Hi, thank you for the video James. I was searching this for two days and I could't understand until I watched this :)
Mind Blown. Thank you for sharing!
Oh jame's, it's beautiful ❤️
Very very nice
very very nice thanks ..
Amazing!!!
Good stuff
That's amazing
Robert deserves an Oscar for his acting.😆
Currently MAUI is not available in the regular VS. It is only for preview mode, when is the availability is going to be in general channel of VS?
great
James, I didn't get you when you said that when we cannot inherit from another class then use "[INotifyPropertyChanged]", if we can, then use inheritance from "ObservableObject". Is it correct? If yes, could you talk about why? Thank you so much! Video time is 12:21 .
Yeah for example... let's say you inherit from your own base class called "MyBaseClass"... well you couldn't inherit from "ObservableObject" at the same time, so this is where you would use "[INotifyPropertyChanged]"
Nice! Thank you so much @@JamesMontemagno !
With no more support for VS for Mac, how do we install the community toolkit to VS Code on Mac?
In minute 6:20 you said don't put the DataContext there. What did you mean by that?
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'. 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?
I added a Xamarin.Forms sample in tehre so take a look at the source code :)
@@JamesMontemagno my question is regarding MAUI, not Xamarin.Forms. Also, my question is regarding using the Page class as the view model for itself, BindingContext = this; your sample does not address my question.
This toolkit espcially targets MVC Web Application developers, right? So I can ignore it as a Blazor dev?
Please, links to this repo
Added links in there
I would love to know When it would come to maui, last time I tried to use it it didn’t work at all
It works perfect with .NET MAUI as I mentioned and have in the sample repo: github.com/jamesmontemagno/MVVMSourceGenerators
Hi, great video! Do you have a navigation example for WPF?
Everyone does navigation in MVVM differently, go with the way that you feel comfortable with.
Yeah the toolkit isn't a framework just helpers and works with every application. So navigation is up to you.
I love helper functions! But I always get imposter syndrome, "how can something so easy, be so good?"
Don't you just love magic codes
Ok now I ll get more stupid using this MVVM thing
wouldn't it be wonderful if you had at least a single sample that u could actually clone from git and compile without throwing visual studio into a shock! the mvvm project is broken, same with the maui sample. just the time spent trying to resolve these conflicts makes you wonder...
Would love to know what issues you are running into. I pulled the source code and is workign just fine. I did a few small tweaks today for styles, but in general working on my machines. please open an issue, but also make sure you are up to date on Visual Studio 2022 previews
Could you provide an example of using attributes to achieve something like a RelayCommand with a CanExecute changed? i.e. You can't hit `Submit` until `!string.IsNullOrWhiteSpace(FullName)` ?
Amazing!