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
@mikp12802 жыл бұрын
This comment saved my day :) Thanks James!
@meilleur1022 жыл бұрын
Hi! Idk if you can help me on one thing. When I create a [ObservableProperty] of anything (string, ObservableCollection etc) the binding work perfectly. When I create a [ObservableProperty ] of a Model, i can't get the ui to update...I really don't get it. When I debug my Model.Properties get updated, but the ui dont. I try UpdateSourceTrigger=PropertyChanged, OneWay, TwoWay etc on the view. Nothing works. Thanks
@paulegan37832 жыл бұрын
Cheers!
@comediehero2 жыл бұрын
Wow, finally something that fixes my biggest gripe with xaml MVVM development. Thx James!
@georgeleithead2 жыл бұрын
Makes the code so much cleaner, and easier to understand for others.
@jontemplin69902 жыл бұрын
This is so awesome! One of the hurdles of understanding and effectively using MVVM was getting your head around all the boilerplate plumbing code and understanding why it's needed. I always thought to myself "why can I just specify properties and commands and let the compiler do all the ceremony?" Yay! It finally happened!
@munver192 жыл бұрын
Great tutorial, Thanks James.
@mrrob14542 жыл бұрын
Amazing. This just made WPF applications 100 times easier. Thanks for the great video.
@JamesMontemagno2 жыл бұрын
You're welcome!
@Otonium2 жыл бұрын
Wow, at last all that tons of lines went away... Keep those in just (a little few) attributes (not towers) thogh Maybe with a comma we'll avoid attributes towers. Great video!😎 James.
@azizjel2 жыл бұрын
Listening to James makes me think of those old grow hair potion salesmen: " Well James, you wrote the ISync command, now What if you want to sink the Submit button and make it sing the song?" James:"Well you just need to carry the CommunityDev boilerplate which comes with the Generator..". Thanks for the the very interesting presentation James though! I like it 🙃😉
@ByronBennett2 жыл бұрын
This is beyond awesome! Super easy to implement. Makes your code soooo lean and easy to read. I love how you can use the code generation where you want to and still go the long route if you need to do stuff in your Get or Set. Excellent code! And a great video showing how to use it!
@JamesMontemagno2 жыл бұрын
Glad you like it!
@xamarinmaster14034 ай бұрын
Awesome! I just tried this against OpenSilver and it works GREAT!
@has_ali2 жыл бұрын
Love to see the excitement in your own expressions, tells you how great it is !
@stevehidem8162 жыл бұрын
Shout out to James! You continue to help me up my game. This MVVM source generator is awesome and I look forward to more updates on recent developments.
@e2a2j2 жыл бұрын
MIND BLOWN! I love this with a passion. This helps reduce stupid errors both in initial creation and going back and modifying. This is awesome. I've used code generators in the past and I love them, but this is next level. Thanks again James!
@JamesMontemagno2 жыл бұрын
🎉🎉🎉
@MaximilienNoal2 жыл бұрын
I was stuck with mvvm since 2010. Now, I finally love it.
@danielblakeley29952 жыл бұрын
The best MVVM content creator ever thanks james.
@jimsimson72662 жыл бұрын
My mind IS blown James! Thank you!
@JesseLiberty2 жыл бұрын
Great, great, great. And as usual, brilliantly described. Nice work James & team.
@Agredo102 жыл бұрын
Wow simply wow! The MCT.MVVM was already very helpful but this is incredible!
@enzodiaz39212 жыл бұрын
You said it: it's ridiculously awesome. I've been working with WINUI 3 and i can see some differences that could be tricky for a newbie like me, but in the road we learn. Thanks James.
@Jgathairu2 жыл бұрын
Thanks James! Amazing and easily broken down. Definitely applying this
@GeorgAubele2 ай бұрын
That is absolutely amazing! Thanks!
@collinsk87542 жыл бұрын
Really great addition to the community toolkit! Thanks a lot for the tutorial.
@JamesMontemagno2 жыл бұрын
Glad you like it!
@zappledd65982 жыл бұрын
Top notch! Nice work.
@ericblankenburg2 жыл бұрын
This is really great. Thanks for posting.
@JamesMontemagno2 жыл бұрын
Glad you enjoyed it!
@malkywullur86832 жыл бұрын
Yes, this would be my 1st personal choice among others mmvm library out there !! Thanks a bunch
@marcelfischer51392 жыл бұрын
James, thank you for this video. I wrote so much code over the last years, that I can now delete. - Just a joke. I definitely check this out!
@LeeM0to2 жыл бұрын
Wow... Game changer. Kudos to all involved. Can't wait to start using it. Thanks for the video James 👍
@matk50872 жыл бұрын
Such a great tool :) thx for sharing!!!!
@LordErnie2 жыл бұрын
Yet again James is here to save the day for devs and students, thanks man.
@TonyHenrique2 жыл бұрын
This is awesome! Very clever implementation.
@paulegan37832 жыл бұрын
Thanks so much James, very nice
@zandyaverhoff95542 жыл бұрын
wow, how many things are change. Thank jame
@kwesiboateng26462 жыл бұрын
My mind was blown james, when you decorated the private fields with ObservableProperty
@billashton65112 жыл бұрын
Looks like the future to me James..!
@emmanueladebiyi21092 жыл бұрын
Truly an awesome library
@MarcJennings2 жыл бұрын
Game changer! Can't wait to get stuck in!
@kosteash2 жыл бұрын
wow James, you are amazing. You showed my so many cool nugets, that make my life easier. Thank you very much !
@RaabStephan2 жыл бұрын
This is honestly pretty amazing!
@suchtendolp6442 жыл бұрын
You changed my life, bro.
@hrishikeshgarud71772 жыл бұрын
Very useful. I was doing everything code behind. Now i will try this.
@belmiris13712 жыл бұрын
It's a great idea. Since I'm a WinForms guy I keep sliding back to it because it's so simple and I can write stuff fast and clean. I tried MVVM again on my latest Xamarin application (since WinForms was not an option) but still ended up using mostly code behind because I found all the MVVM stuff just too hard to keep track of and getting it to work cleanly with the UI was just too daunting. If these people can make it less complicated that would be great. I DID find the code it generated very scary looking though. If I get some bizarre error about eyepoke() not properly initialized or the my app just hanging or disappearing I would probably give up and go simple again.
@anderson.damasio2 жыл бұрын
very good this! James
@Gazcan2 жыл бұрын
This is so good, that it makes me wonder why this wasn't there with the release of WPF.
@anandshindey2 жыл бұрын
This is awesome. Thanks James.
@Albahadly2 жыл бұрын
Thanks James, you really treasure
@kashifenet19832 жыл бұрын
Cool that is too much life will be easy after using this Thank you JM
@MarekLS602 жыл бұрын
Great tutorial !!!
@kamertonaudiophileplayer8472 жыл бұрын
I am with you. I created a source generator for MVVM 7 years ago, and since then I stopped writing a lot of a code. Everything is done by the source generator. Continue to propagate the idea.
@ostelaymetaule2 жыл бұрын
How many juniour developers could understand and extend on your code without wondering about black magic and stuff? D: I am very very cautious every time I see some work being done in background by some sort of extensions or dynamic code generation or self invented conventions nobody else in the world knows about. One thing is to rely on ms own attributes and conventions with tons of documentation and tests and usage and another is thinking that I am able to create, support and fix this on my own and that when I quit the job the next guy will know what the hell is happening in the code
@kamertonaudiophileplayer8472 жыл бұрын
@@ostelaymetaule It is a very good concern and actually I had a fear that simply developers will run away. But to my surprise, a feedback was completely opposite. They gladly started using it. Why? If system is designed well, it is so natural and intuitive, developers on any level, especially juniors, just use it.
@ostelaymetaule2 жыл бұрын
@@kamertonaudiophileplayer847 I am glad to hear you managed to make it work, I have seen couple examples earlier in my career as well, but also encountered some over engineered magic bazoongas nobody knows what it does and the original dev is long gone ;)
@kamertonaudiophileplayer8472 жыл бұрын
@@ostelaymetaule It is normal, we lost several good developers exactly for the reason. Some system for some reason wasn't designed by us well. The result was really disappointing, we started loosing people because they simply can't use the system. Solution? Do not be afraid of to redesign the system instead of trying to fix it little by little.
@astrowalker26292 жыл бұрын
Awesome, thank you very much. Now I am on the hunt for some good tutorials how to create such generators by myself 🙂.
@L-E-son2 жыл бұрын
VERY cool! Thanks for sharing!
@ignispurgatorius5297 Жыл бұрын
While I've gotten used to MVVM in WPF, at the end of the day I'm still not convinced it is actually nearly as good a pattern as the head-in-the-clounds programers make it out to be. The reality of my (and I think many others) is simply not at the scale where we really profit from it. Back when we switched to it, it was sold with the promises of having the option to easily outsource the view design (because of the decoupling), being unit testable and being oh-so-efficient. After working with it for years, I have to say that I still end up writing most if not all of my view code myself. I have barely written any unit tests, because the stuff that actually fails is way to much effort to unit test and the simple stuff I have clicked through quicker than I've set up the test. And lastly I don't think having to do 3 things to handle a button event or drowning in property boilerplate code has made the code any more readable or quicker to produce. The tiny bit of intellisense support you get from it hardly makes it worth it imho. I know there are plenty of nugets and extension to help with this and we've used a couple of them mostly successfully over the years, but it never really felt like at the base the effort was worth it That being said, seeing this auto code generation I feel like we've finally reached a the point where the extra effort has been reduced to a level that no longer negates all the smaller benefits (I will probably still not write alot of unit tests or have some of those mythical html programmers swoop in and design beautiful GUIs for me :P). I just wish I could actually use it in all the older projets we still have to maintain, but sadly they are still mostly on .Net4.7. Well at least going forward it will become alot nicer.
@chandra_arifin2 жыл бұрын
Awesome... Like it so much. 😍😍😍👍👍👍
@soixantelly2 жыл бұрын
MVVM is now practical with this
@ghanimalmarzouqi32772 жыл бұрын
Many thanks to you James. This is really helpful and blowing my mind too 🤯🤯🤩.
@joehanna_2 жыл бұрын
Sweet! I use base classes to do some of that but it is not a lovely as using the attributes with the generators. The new code feels right and clean. Chunky boilerplate code has always felt dirty
@worknaturebalance2 жыл бұрын
Hey James. You can do this for many years using propertychanged.fody nuget package. What is even better it can do this without all those attributes. Especially combined values like Full name from your example. You can use them directly without specifying that it should be updated in other properties attribute. The thing about ICommand is quite neat in your presentation, this is currently not present in propertychanged.fody But also it's quite small price to pay in comparison with all the boilerplate code for properties. On a side note. Keep up the good work. I was using many packages of yours for few years already. Thank you for every single one of them. Cheers
@JamesMontemagno2 жыл бұрын
I should have talked a bit about fody a bit in there. It is more assembly weaving to manipulate IL from my understanding. Where this is source generators where they are generated instantly without compilation. Correct me if I am wrong.
@EngLuizFranco2 жыл бұрын
@@JamesMontemagno You're right. Despite fody adding zero boilerplate, you do not have access to the generated code, because its generated at compile time. With source generators, you can see in real time all the code that is generated which is awesome in my opinion and gives us the opportunity to learn new things by exploring the generated code.
@williamliu89852 жыл бұрын
@@JamesMontemagno I think the source generator might not be mature enough at this time. It sometimes bring in strange issues and I should reload the project for fixing it. Hope MSFT can make this tool much better.
@worknaturebalance2 жыл бұрын
@@JamesMontemagno as Luiz said, you are absolutely right. Source generators have other benefits, but also propertychanged.fody gives you the same outcome with cleaner code (no attributes needed). Also I don't remember if I ever needed to inspect the code that got generated. In most cases it's quite simple. Would it be possible to use source generators without those attributes?
@morgenrot26402 жыл бұрын
@@williamliu8985 Unfortunately, I had to find that out too.
@mashrulhaque11682 жыл бұрын
Thank you so much James
@ramigamal6637 Жыл бұрын
An amazing tool I am using it for about a year -_-
@isax552 жыл бұрын
Hooo, I need to update my projects right now!!
@mubarekabdi2 жыл бұрын
Super useful ! Thanks 👍
@abba51022 жыл бұрын
Waw that's awesome thank you sir.
@felipeapj2 жыл бұрын
I wish a can give more than just a thumbs up, thats awesome!!!
@billymartin64972 жыл бұрын
Great video, as usual, James. Couple quick questions: How do we pass command parameters? Does it function inside of VS 2019? Sometimes we have to drop back to use the MultiLingual extension, since it's not in VS 2022.
@JamesMontemagno2 жыл бұрын
I believe they should, but I only have 2022 on my machines now
@Sergio06942 жыл бұрын
You can pass command parameter through whatever system the UI framework you're using has, that's separate from the command implementations the MVVM Toolkit has (for instance, on WPF/UWP/WinUI you'd do CommandParameter="{Binding ...}", or {x:Bind ...}, etc.). As for VS2019, no the generators will not work there. For the 8.0.0 release of the MVVM Toolkit I've rewritten all of them to be incremental generators, and that feature needs Roslyn 4.x to work, which isn't available on VS2019. You'll need VS2022 for that (or another modern IDE of your choice, eg. Rider). Hope this helps!
@JamesMontemagno2 жыл бұрын
Checkout github.com/CommunityToolkit/dotnet/issues/158 for a working sample, You will need to put things in a .NET Standard library for it to fully work.
@PticostaricaGS2 жыл бұрын
Excellent video, and great topic, there is still a lack of video-content on Source Generators
@origamiiekiller2 жыл бұрын
Hi James, Great content and thank you for bringing this to my attention, seems to work perfectly in your demo. Small question: You had an example with the asynchronous command. Will the binding still work if I postfix the name of the method to 'SubmitAsync'? Or does the generated binding only work, because the name is 'Submit' for the method and 'SubmitCommand' in the Xaml?
@shrikantthorve57012 жыл бұрын
Thank you James for really nice video.. One suggestion, could you please create video on DeepLinking where application can launch from url like Amazon...
@buddysnackit17582 жыл бұрын
I actually made a post about "Why doesn't a system that generates the MVVM code for you!" in one of your older videos! Yes!
@JamesMontemagno2 жыл бұрын
🎉🎉🎉🎉
@Proto612 жыл бұрын
Thank you for the awesome video, could you make a video how to use Messengers with the toolkit? And a video for navigation would be also very nice. Thank you!
@h3ferdinand2 жыл бұрын
Great!! Thanks for sharing
@ali_jb9411 ай бұрын
Fantastic video,!
@JamesMontemagno11 ай бұрын
Glad you liked it!
@marufahmad43852 жыл бұрын
Thanks for the great content. Can you please also make a video on MVVM Messaging?
@Sajgoniarz2 жыл бұрын
Amazing stuff, thanks You very much! I'm writing a simple app for my team and i just can't wrap my head around how inefficient to write is WPF.
@MohitKesarwaniPhoton2 жыл бұрын
Amazing that is what I wanted
@MohitKesarwaniPhoton2 жыл бұрын
Coz I am lazy :) 🤣🤣🤣🤣
@JoseSilva-gt6zj2 жыл бұрын
Awesome explanation, James! Thank you! Let me ask about obfuscation. Do you know if it works after obfuscating the code? I mean for a WPF app. Thanks!
@JamesMontemagno2 жыл бұрын
Yes it does from my understanding, it is the same as if you wrote the code ;)
@ababacarcisse79692 жыл бұрын
I like your plugin Media❤️
@jewersp2 жыл бұрын
Hi James. This is pretty awesome. The pattern with the if(SetProperty(...)) { ... } is not new to me, I've been using that already for a while now since MvvmLight allowed me to do the same thing, except for the code generation part of it. Does this mean that we can reuse our ViewModels and share them between Xamarin/MAUI and WPF applications? Does the new Community Toolkit also include ICommand derivatives and implementations for IAsyncCommand like the Xamarin Community Toolkit does? BTW, I absolutely love that we can update the canExecute flag of Commands using attributes now, it takes away a lot of messy code pain.
@JamesMontemagno2 жыл бұрын
It does, it included RelayCommand and AsyncRelayCommand or something like that, it is what it generates
@jewersp2 жыл бұрын
@@JamesMontemagno that's awesome. Thanks! 😊
@rxtx39482 жыл бұрын
Stunning beautiful
@RajK092 жыл бұрын
It'll be very useful. What if we'd like to call a method when a property has changed?
@МаксимАдаменко2 жыл бұрын
OMG this cool!
@scara17012 жыл бұрын
This is awesome!
@zappledd65982 жыл бұрын
Hi James, I love your tutorials. I've been diving a bit deeper into the MMVM Toolkit as I steadily replace my old MVVMLight code. One area not covered in your video that I'd like some more insight into is the ICommand "RaiseCanExecuteChanged". I'm seeing things like [NotifyCanExecuteChangedFor] in the new Toolkit that looks promising. Do you have a video that covers this or can you point me somewhere that might? Thanks so much.
@WarBorg2 жыл бұрын
hey James, awesome video as always, one question sits on my mind, how does this work with the xamarin community toolkit and the future MAUI community toolkit, as I see some overlapping bits, thx!
@JamesMontemagno2 жыл бұрын
So they are all on the same GitHub organization now and are aligned. The genera .NET one will focus on full compatibility with all .NET apps and then the individual one will be specific to the frameworks and they are working on minimizing any overlap
@WarBorg2 жыл бұрын
@@JamesMontemagno awesome thx for the answer, I really like the code generated stuff but I would like to use the xamarin / Maui community toolkit as well and not have to worry about using the wrong namespace :D
@nixnemo2 жыл бұрын
Looks/sounds amazing. Many thanks for the efforts. If [ObservableProperty] attribute would work without compilation error, telling MyViewModel already exists, I would really appreciate. Many thanks in advance. Again, really appreciate what you done.
@ssg32192 жыл бұрын
AlsoNotifyCanExecuteFor() and the AllowConcurrentExecutions flag are currently missing from the Community Toolkit. Will they be coming back? If not, how should that functionality be implemented?
@tonycaesar79342 жыл бұрын
Thanks, James. I haven't been a fan of magic source generators for awhile. I have been using a library of my own with all the necessary boilerplate. This could simplify things and reduce the number of keystrokes needed. However, I did run into one problem. I have a BaseViewModel for may pages with things like the page title and analytics services common to all page view models in my project. The source generator stops generating code as soon as I inherit from BaseViewModel. Without the base view model, I have to type (or copy paste) just as much code as is eliminated by the source generator. Thus not much of a win for me in total. I suppose I could trick this systems and add the inheritance at the end, but I'm sure I'll forget in a year when I add a new property to the view model. Is there a better workaround for this scenario?
@JamesMontemagno2 жыл бұрын
Hmmmmm this should totally work as I do this in the workshop I am working on.... not sure why it wouldn't work.... If you have a sample repo send it over to me via twitter or email so I can look
@kevinmellor551 Жыл бұрын
@@JamesMontemagno I have the same problem - did you uncover a reason and/or solution? Thanks.
@kevinmellor551 Жыл бұрын
Fixed - my base class was using the wrong ObservableObject - from Xamarin.CommunityToolkit.ObjectModel instead of CommunityToolkit.Mvvm.ComponentModel
@solomonfried70182 жыл бұрын
Incredible tool! Thanks. How is Can Execute Command implemented?
@williamliu89852 жыл бұрын
+1
@JamesMontemagno2 жыл бұрын
Good question, checkout the blog for sure -> devblogs.microsoft.com/ifdef-windows/announcing-net-community-toolkit-v8-0-0-preview-1/ You can do -> [AlsoNotifyCanExecuteFor] on a property
@gwisekor2 жыл бұрын
+1
@robertodalmonte5042 жыл бұрын
I had same question myself... [INotifyPropertyChanged] public partial class MainWindowViewModel { [ObservableProperty] [AlsoNotifyChangeFor(nameof(FullName))] [AlsoNotifyCanExecuteFor(nameof(ShowCommand))] private string firstName = string.Empty; [ObservableProperty] [AlsoNotifyChangeFor(nameof(FullName))] [AlsoNotifyCanExecuteFor(nameof(ShowCommand))] private string lastName = string.Empty; public string FullName => $"{LastName} {FirstName}"; public bool CanShow { get => firstName.Length > 2 && lastName.Length > 2; } [ICommand(CanExecute = nameof(CanShow))] private void Show() { MessageBox.Show(FullName); } partial void OnFirstNameChanged(string value) { if (CanShow) { MessageBox.Show($"Execute Custom code on {value}"); } } } XAML:
@waynemv2 жыл бұрын
Is there a source generator or other clean way to add undo/redo functionality to the form in your example?
@doublebass1202 жыл бұрын
Excellent library, great video! Does this also work for Xamarin Forms and WPF?
@JamesMontemagno2 жыл бұрын
Yes it does!
@royeagle2 жыл бұрын
I tried it but I get “This generator is not generating files…”
@royeagle2 жыл бұрын
@@JamesMontemagno I can get the ObservableProperty to work after changing to C# 9 in Xamarin Forms. Can't get the ICommand to work, the method is never called. Ver 8.0 preview2.
@royeagle2 жыл бұрын
I figured it out. I named my method ClickMeCommand and it did not work. I changed it to ClickMe and now it works.
@WilliamCarinci Жыл бұрын
In using the MVVM pattern, how do you go about handling Navigation.PushModalAsync when it often expects a parameter of type Page? In particular, this seems to be a concern of mine when handling a page NOT defined as a shell page. For instance, a settings modal. It seems peculiar that you get caught in an issue where the .xaml.cs of a page gets set with the BindingContext = viewModel.
@RebrandSoon00002 жыл бұрын
James, I am confused on this method, how do I add a Model to this? or does it all go in ViewModels?
@miguelmunozluman47322 жыл бұрын
Sorcery! jajaja what amazing change!
@ArabGirlLifestyle2 жыл бұрын
Doesn't work with VS for Mac in Xamarin for iOS or Android :(
@JamesMontemagno2 жыл бұрын
Source generators will need the latest version of .NET installed on the machine. I would test out VS 2022 preview and it should work there.
@michaldivismusic2 жыл бұрын
I'll be able to remove about a 1/4 of all the code from my projects, awesome!
@JamesMontemagno2 жыл бұрын
That’s awesome!!!
@stasasekulic6917 Жыл бұрын
Can you create some advanced tutorial on this? Navigation bar with views, commands and stuff?
@hernanlanusse5558 Жыл бұрын
Hi James, how can I implement an ObservableCollection using this method?
@GuperGER2 жыл бұрын
Hey James, great video! Do you know if it's possible to call a method on a property change? Say FirstName changes and I want to call a method where I use the new value. It would be awesome if there would be something like [CallOnPropertyChange(Action action)]
@JamesMontemagno2 жыл бұрын
Not sure, but open up a suggestion on GitHub
@Sergio06942 жыл бұрын
Hey there! Yes, you can do this as well. In the new 8.0.0-Preview2 version (we released it just this Thursday), the ObservableProperty generator also generates two partial methods: OnPropertyChanging and Changing (the name will match the one of that property). You can define them in your code and from there execute all custom logic if needed. The cool thing is that if you don't, those methods are just removed entirely from the compiler, so there's no overhead at all. Basically just do this: [ObservableProperty] private string name; partial void OnNameChanged(string value) { Console.WriteLine($"Hello {value}!"); } Hope this helps! I'll be including all this in a proper blog post once we ship 8.0.0 for good 😄
@JockHartvig2 жыл бұрын
@@Sergio0694 I Had the same problem. Nice implementation.
@nyumbanikwetu91942 жыл бұрын
It seems I can't user interface beside ObservableObject, is there a way around this? Is it possible to do: public partial class NameViewModel : ObservableObject , IName
@anmolbehl85722 жыл бұрын
Hi James, I want to add some logic within my properties. Example: For a particular entry for Age from the UI we can set a property if the person is eligible to vote or not and display it on the UI. Can you suggest a way how this would be implemented using CommunityToolkit.Mvvm? Best Regards