MVVM Source Generators: Never Write MVVM Boilerplate Code Again!

  Рет қаралды 78,048

James Montemagno

James Montemagno

Күн бұрын

Пікірлер: 293
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
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
@mikp1280
@mikp1280 2 жыл бұрын
This comment saved my day :) Thanks James!
@meilleur102
@meilleur102 2 жыл бұрын
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
@paulegan3783
@paulegan3783 2 жыл бұрын
Cheers!
@comediehero
@comediehero 2 жыл бұрын
Wow, finally something that fixes my biggest gripe with xaml MVVM development. Thx James!
@georgeleithead
@georgeleithead 2 жыл бұрын
Makes the code so much cleaner, and easier to understand for others.
@jontemplin6990
@jontemplin6990 2 жыл бұрын
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!
@munver19
@munver19 2 жыл бұрын
Great tutorial, Thanks James.
@mrrob1454
@mrrob1454 2 жыл бұрын
Amazing. This just made WPF applications 100 times easier. Thanks for the great video.
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
You're welcome!
@Otonium
@Otonium 2 жыл бұрын
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.
@azizjel
@azizjel 2 жыл бұрын
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 🙃😉
@ByronBennett
@ByronBennett 2 жыл бұрын
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!
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
Glad you like it!
@xamarinmaster1403
@xamarinmaster1403 4 ай бұрын
Awesome! I just tried this against OpenSilver and it works GREAT!
@has_ali
@has_ali 2 жыл бұрын
Love to see the excitement in your own expressions, tells you how great it is !
@stevehidem816
@stevehidem816 2 жыл бұрын
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.
@e2a2j
@e2a2j 2 жыл бұрын
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!
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
🎉🎉🎉
@MaximilienNoal
@MaximilienNoal 2 жыл бұрын
I was stuck with mvvm since 2010. Now, I finally love it.
@danielblakeley2995
@danielblakeley2995 2 жыл бұрын
The best MVVM content creator ever thanks james.
@jimsimson7266
@jimsimson7266 2 жыл бұрын
My mind IS blown James! Thank you!
@JesseLiberty
@JesseLiberty 2 жыл бұрын
Great, great, great. And as usual, brilliantly described. Nice work James & team.
@Agredo10
@Agredo10 2 жыл бұрын
Wow simply wow! The MCT.MVVM was already very helpful but this is incredible!
@enzodiaz3921
@enzodiaz3921 2 жыл бұрын
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.
@Jgathairu
@Jgathairu 2 жыл бұрын
Thanks James! Amazing and easily broken down. Definitely applying this
@GeorgAubele
@GeorgAubele 2 ай бұрын
That is absolutely amazing! Thanks!
@collinsk8754
@collinsk8754 2 жыл бұрын
Really great addition to the community toolkit! Thanks a lot for the tutorial.
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
Glad you like it!
@zappledd6598
@zappledd6598 2 жыл бұрын
Top notch! Nice work.
@ericblankenburg
@ericblankenburg 2 жыл бұрын
This is really great. Thanks for posting.
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
Glad you enjoyed it!
@malkywullur8683
@malkywullur8683 2 жыл бұрын
Yes, this would be my 1st personal choice among others mmvm library out there !! Thanks a bunch
@marcelfischer5139
@marcelfischer5139 2 жыл бұрын
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!
@LeeM0to
@LeeM0to 2 жыл бұрын
Wow... Game changer. Kudos to all involved. Can't wait to start using it. Thanks for the video James 👍
@matk5087
@matk5087 2 жыл бұрын
Such a great tool :) thx for sharing!!!!
@LordErnie
@LordErnie 2 жыл бұрын
Yet again James is here to save the day for devs and students, thanks man.
@TonyHenrique
@TonyHenrique 2 жыл бұрын
This is awesome! Very clever implementation.
@paulegan3783
@paulegan3783 2 жыл бұрын
Thanks so much James, very nice
@zandyaverhoff9554
@zandyaverhoff9554 2 жыл бұрын
wow, how many things are change. Thank jame
@kwesiboateng2646
@kwesiboateng2646 2 жыл бұрын
My mind was blown james, when you decorated the private fields with ObservableProperty
@billashton6511
@billashton6511 2 жыл бұрын
Looks like the future to me James..!
@emmanueladebiyi2109
@emmanueladebiyi2109 2 жыл бұрын
Truly an awesome library
@MarcJennings
@MarcJennings 2 жыл бұрын
Game changer! Can't wait to get stuck in!
@kosteash
@kosteash 2 жыл бұрын
wow James, you are amazing. You showed my so many cool nugets, that make my life easier. Thank you very much !
@RaabStephan
@RaabStephan 2 жыл бұрын
This is honestly pretty amazing!
@suchtendolp644
@suchtendolp644 2 жыл бұрын
You changed my life, bro.
@hrishikeshgarud7177
@hrishikeshgarud7177 2 жыл бұрын
Very useful. I was doing everything code behind. Now i will try this.
@belmiris1371
@belmiris1371 2 жыл бұрын
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.damasio
@anderson.damasio 2 жыл бұрын
very good this! James
@Gazcan
@Gazcan 2 жыл бұрын
This is so good, that it makes me wonder why this wasn't there with the release of WPF.
@anandshindey
@anandshindey 2 жыл бұрын
This is awesome. Thanks James.
@Albahadly
@Albahadly 2 жыл бұрын
Thanks James, you really treasure
@kashifenet1983
@kashifenet1983 2 жыл бұрын
Cool that is too much life will be easy after using this Thank you JM
@MarekLS60
@MarekLS60 2 жыл бұрын
Great tutorial !!!
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 2 жыл бұрын
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.
@ostelaymetaule
@ostelaymetaule 2 жыл бұрын
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
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 2 жыл бұрын
@@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.
@ostelaymetaule
@ostelaymetaule 2 жыл бұрын
@@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 ;)
@kamertonaudiophileplayer847
@kamertonaudiophileplayer847 2 жыл бұрын
@@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.
@astrowalker2629
@astrowalker2629 2 жыл бұрын
Awesome, thank you very much. Now I am on the hunt for some good tutorials how to create such generators by myself 🙂.
@L-E-son
@L-E-son 2 жыл бұрын
VERY cool! Thanks for sharing!
@ignispurgatorius5297
@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_arifin
@chandra_arifin 2 жыл бұрын
Awesome... Like it so much. 😍😍😍👍👍👍
@soixantelly
@soixantelly 2 жыл бұрын
MVVM is now practical with this
@ghanimalmarzouqi3277
@ghanimalmarzouqi3277 2 жыл бұрын
Many thanks to you James. This is really helpful and blowing my mind too 🤯🤯🤩.
@joehanna_
@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
@worknaturebalance
@worknaturebalance 2 жыл бұрын
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
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
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.
@EngLuizFranco
@EngLuizFranco 2 жыл бұрын
@@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.
@williamliu8985
@williamliu8985 2 жыл бұрын
@@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.
@worknaturebalance
@worknaturebalance 2 жыл бұрын
@@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?
@morgenrot2640
@morgenrot2640 2 жыл бұрын
@@williamliu8985 Unfortunately, I had to find that out too.
@mashrulhaque1168
@mashrulhaque1168 2 жыл бұрын
Thank you so much James
@ramigamal6637
@ramigamal6637 Жыл бұрын
An amazing tool I am using it for about a year -_-
@isax55
@isax55 2 жыл бұрын
Hooo, I need to update my projects right now!!
@mubarekabdi
@mubarekabdi 2 жыл бұрын
Super useful ! Thanks 👍
@abba5102
@abba5102 2 жыл бұрын
Waw that's awesome thank you sir.
@felipeapj
@felipeapj 2 жыл бұрын
I wish a can give more than just a thumbs up, thats awesome!!!
@billymartin6497
@billymartin6497 2 жыл бұрын
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.
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
I believe they should, but I only have 2022 on my machines now
@Sergio0694
@Sergio0694 2 жыл бұрын
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!
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
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.
@PticostaricaGS
@PticostaricaGS 2 жыл бұрын
Excellent video, and great topic, there is still a lack of video-content on Source Generators
@origamiiekiller
@origamiiekiller 2 жыл бұрын
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?
@shrikantthorve5701
@shrikantthorve5701 2 жыл бұрын
Thank you James for really nice video.. One suggestion, could you please create video on DeepLinking where application can launch from url like Amazon...
@buddysnackit1758
@buddysnackit1758 2 жыл бұрын
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!
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
🎉🎉🎉🎉
@Proto61
@Proto61 2 жыл бұрын
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!
@h3ferdinand
@h3ferdinand 2 жыл бұрын
Great!! Thanks for sharing
@ali_jb94
@ali_jb94 11 ай бұрын
Fantastic video,!
@JamesMontemagno
@JamesMontemagno 11 ай бұрын
Glad you liked it!
@marufahmad4385
@marufahmad4385 2 жыл бұрын
Thanks for the great content. Can you please also make a video on MVVM Messaging?
@Sajgoniarz
@Sajgoniarz 2 жыл бұрын
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.
@MohitKesarwaniPhoton
@MohitKesarwaniPhoton 2 жыл бұрын
Amazing that is what I wanted
@MohitKesarwaniPhoton
@MohitKesarwaniPhoton 2 жыл бұрын
Coz I am lazy :) 🤣🤣🤣🤣
@JoseSilva-gt6zj
@JoseSilva-gt6zj 2 жыл бұрын
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!
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
Yes it does from my understanding, it is the same as if you wrote the code ;)
@ababacarcisse7969
@ababacarcisse7969 2 жыл бұрын
I like your plugin Media❤️
@jewersp
@jewersp 2 жыл бұрын
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.
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
It does, it included RelayCommand and AsyncRelayCommand or something like that, it is what it generates
@jewersp
@jewersp 2 жыл бұрын
@@JamesMontemagno that's awesome. Thanks! 😊
@rxtx3948
@rxtx3948 2 жыл бұрын
Stunning beautiful
@RajK09
@RajK09 2 жыл бұрын
It'll be very useful. What if we'd like to call a method when a property has changed?
@МаксимАдаменко
@МаксимАдаменко 2 жыл бұрын
OMG this cool!
@scara1701
@scara1701 2 жыл бұрын
This is awesome!
@zappledd6598
@zappledd6598 2 жыл бұрын
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.
@WarBorg
@WarBorg 2 жыл бұрын
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!
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
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
@WarBorg
@WarBorg 2 жыл бұрын
@@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
@nixnemo
@nixnemo 2 жыл бұрын
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.
@ssg3219
@ssg3219 2 жыл бұрын
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?
@tonycaesar7934
@tonycaesar7934 2 жыл бұрын
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?
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
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
@kevinmellor551 Жыл бұрын
@@JamesMontemagno I have the same problem - did you uncover a reason and/or solution? Thanks.
@kevinmellor551
@kevinmellor551 Жыл бұрын
Fixed - my base class was using the wrong ObservableObject - from Xamarin.CommunityToolkit.ObjectModel instead of CommunityToolkit.Mvvm.ComponentModel
@solomonfried7018
@solomonfried7018 2 жыл бұрын
Incredible tool! Thanks. How is Can Execute Command implemented?
@williamliu8985
@williamliu8985 2 жыл бұрын
+1
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
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
@gwisekor
@gwisekor 2 жыл бұрын
+1
@robertodalmonte504
@robertodalmonte504 2 жыл бұрын
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:
@waynemv
@waynemv 2 жыл бұрын
Is there a source generator or other clean way to add undo/redo functionality to the form in your example?
@doublebass120
@doublebass120 2 жыл бұрын
Excellent library, great video! Does this also work for Xamarin Forms and WPF?
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
Yes it does!
@royeagle
@royeagle 2 жыл бұрын
I tried it but I get “This generator is not generating files…”
@royeagle
@royeagle 2 жыл бұрын
@@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.
@royeagle
@royeagle 2 жыл бұрын
I figured it out. I named my method ClickMeCommand and it did not work. I changed it to ClickMe and now it works.
@WilliamCarinci
@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.
@RebrandSoon0000
@RebrandSoon0000 2 жыл бұрын
James, I am confused on this method, how do I add a Model to this? or does it all go in ViewModels?
@miguelmunozluman4732
@miguelmunozluman4732 2 жыл бұрын
Sorcery! jajaja what amazing change!
@ArabGirlLifestyle
@ArabGirlLifestyle 2 жыл бұрын
Doesn't work with VS for Mac in Xamarin for iOS or Android :(
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
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.
@michaldivismusic
@michaldivismusic 2 жыл бұрын
I'll be able to remove about a 1/4 of all the code from my projects, awesome!
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
That’s awesome!!!
@stasasekulic6917
@stasasekulic6917 Жыл бұрын
Can you create some advanced tutorial on this? Navigation bar with views, commands and stuff?
@hernanlanusse5558
@hernanlanusse5558 Жыл бұрын
Hi James, how can I implement an ObservableCollection using this method?
@GuperGER
@GuperGER 2 жыл бұрын
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)]
@JamesMontemagno
@JamesMontemagno 2 жыл бұрын
Not sure, but open up a suggestion on GitHub
@Sergio0694
@Sergio0694 2 жыл бұрын
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 😄
@JockHartvig
@JockHartvig 2 жыл бұрын
@@Sergio0694 I Had the same problem. Nice implementation.
@nyumbanikwetu9194
@nyumbanikwetu9194 2 жыл бұрын
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
@anmolbehl8572
@anmolbehl8572 2 жыл бұрын
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
@jhanifkara8552
@jhanifkara8552 2 жыл бұрын
INCREDIBLE 🙈
@tarsisf8173
@tarsisf8173 2 жыл бұрын
Fantastic!!!
What is the MVVM pattern, What benefits does MVVM have?
22:38
James Montemagno
Рет қаралды 103 М.
Жездуха 41-серия
36:26
Million Show
Рет қаралды 5 МЛН
SLIDE #shortssprintbrasil
0:31
Natan por Aí
Рет қаралды 49 МЛН
8 await async mistakes that you SHOULD avoid in .NET
21:13
Nick Chapsas
Рет қаралды 316 М.
How much does the Windows Community MVVM Toolkit REALLY help us?
7:02
Build Better Apps with .NET Aspire - Complete Beginner's Guide & Tutorial
1:12:47
Better MVVM with MVVM Helpers
21:17
James Montemagno
Рет қаралды 46 М.
Forget Controllers and Minimal APIs in .NET!
14:07
Nick Chapsas
Рет қаралды 79 М.
Dependency Injection with .NET MAUI Explained! Full Beginner's Guide
19:18
Can we control AI?
24:09
Welch Labs
Рет қаралды 83 М.
.NET Community Toolkit
24:15
Microsoft Visual Studio
Рет қаралды 13 М.
5 Ways to Make Money As A Mobile App Developer
16:18
James Montemagno
Рет қаралды 9 М.
.NET MAUI Explained: What is it, How does it work, and What about Blazor?
34:28