MVVM stands for Model-View-ViewModel, so i naturally imagine 3 files, the View, the ViewModel and the Model, but here and all other videos about it i only see 2 files being implemented, the View and the ViewModel but not the Model... so why it's not implemented? and what is the diference (when the Model file is implemented) on ViewModel?
This is defenitely the best video about mvvm. Quick question, Everyone uses fields and properties, you just skip the field and use the property, directly why is that?
Hello sir , Your way to explain is super easy but videos should have an order . And One can easily learn by following the playlist, I mean there should be hierarchy of concepts from scratch to advance . Thanks
Hi Gerald, excellent video, i have a little question, we execute the commands from the xaml side of our view, but its a violation if we do it from code-behind? Let me explain, I need to populate a ListView when the view is loaded and i achieved this by: // C# code MyViewModel vm = (MyViewModel)BindingContext; vm.PopulateListViewCommand.Execute(null); // Using this in the code behind, its a MVVM violation?
Nice video as always, love watching them as they are short and to the point ... but can you make some video about MVVM frameworks (CrosMVVM, LightMVVM, FreshMVVM ...) I think some of them are discontinued and will not be maintained anymore .. like LightMVVM .. some pros and cons (this one is lightest and fastest but doesn't have this or that or CrossMVVM has it all but its robust)
Thanks Matija! I will look into that! Note that MvvmLight (I assume you mean :)) is no longer maintained and you should now use CommunityToolkit.Mvvm which is the successor!
@@jfversluis does the PropertyChanged event implementaton get invoked automatically and change the XAML or is invoking it manually as you have done in the OnPropertyChanged method required?
@@MrRobravens Ah you will need that, but I think it's there by default on all the Xamarin.Forms controls. It will be invoked automatically by the XAML binding engine indeed
Hi Gerald. I specify the ViewModel in the xaml using a section. Intellisense works great then. But if I initialize the binding context in the page constructor (because I have to pass some parameters) the ViewModel gets initialized twice, once without and once with the parameter(s). Is there a way to prevent this? Or doing it a better way?
@@jfversluis I don't think this is what mean. I open a new page for a tapped product or something with new Page(productid). In the codebehind of this page I set de BindingContext to new ViewModel(productId) in the constructor of that page that accepts this parameter. So there are 2 constructors in this viewmodel, one without and one with a parameter. This viewmodel is referenced in the xaml so intellisense works correct. But when this page in opened the reference in the xaml causes the viewmodel te be initialized with a call to the default constructor and the call to new ViewModel(id) in the page codebehind causes the ViewModel to be initialized again with the call to de contructor accepting that parameter. It works, but costs time and extra resources. What is the 'normal' way to do this? Last solution a came up with is: because the reference in the xaml initializes the viewmodel already, so in the page codebehind I only set a property of the BindingContext to the productId. (Or call a method if it needs te be async)
@@KeesAlderliesten There is a lot in here 😄 not sure if UA-cam comments is the best way to answer this. I think you might want to look at compiled bindings which still gives you IntelliSense but doesn't create an instance of your view model: docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/data-binding/compiled-bindings I think when I used to build this I would just have 1 constructor and pass in a -1 or null or something whenever I needed something new. But that's mostly dependant on preference and requirements.
Hi is it possible to inject the view model into the code-behind. Im using Autofac, but Im having trouble cause it seems that WPF only calls the default constructor of the code-behind and thus my injected types doesn't get injected.
If I have a single button to push a new Navigation page, should it's function be included in the Model class or simply implement the OnClick function in code-behind?
I have solved this issue, without using command, but activating property in the right moment, thanks for the video that was the base to achieve use of activity indicator at demmand
I love MVVM pattern ♥.....(btw) let you know, I finally got my macbook pro, I haven't installed anything yet but when I set it ready, I'll let you know about my experience
Hm not sure what you mean? It will use .NET 6, which is the continuation of .NET Core, so yeah it should be able to run on a desktop with it's own runtime version
@@jfversluis if u can in the future make like a todo list app CRUD operations and UI made with MVVM but without MVVM Frameworks or packages to be albe to understand how things works and tnx a lottt
I'm sorry, I don't have such a printer around so I can't make that video :) Maybe this helps: www.xamboy.com/2020/04/20/bluetooth-printing-in-xamarin-forms-using-shiny/
Thank you! Finally a concise and smart way to explain MVVM.
Glad you liked it!!
MVVM stands for Model-View-ViewModel, so i naturally imagine 3 files, the View, the ViewModel and the Model, but here and all other videos about it i only see 2 files being implemented, the View and the ViewModel but not the Model... so why it's not implemented? and what is the diference (when the Model file is implemented) on ViewModel?
Good stuff. MVVM is a life saver. The number of times my UI has changed, I would go crazy without MVVM. Cheers.
Haha that is great to hear!
Gerald, appreciate your work! Awesome and helpful vid :)
Thanks for taking the time to let me know Alexey!
Thanks - good to understand!
This is defenitely the best video about mvvm.
Quick question, Everyone uses fields and properties, you just skip the field and use the property, directly why is that?
Love the video. Communication skills are excellent. Would it be possible to incorporate MVVM demo into a Flyout type project?
You mean using MVVM with a Flyout page?
Hi Gerald, Thank you very much for your video.
You’re welcome!
Excellent Video, excellent explanation. 🔥
Thank you so much!
Hello sir , Your way to explain is super easy but videos should have an order . And One can easily learn by following the playlist, I mean there should be hierarchy of concepts from scratch to advance . Thanks
Thanks for the suggestion!
Dankjewel man, mega goede uitleg!
Goed om te horen, dank je wel!
thank you, question how do i call a control event with a command, the control is in a page content
Awesome vid! Could you do a full series on all things mvvm?
I think a lot of people would like that. Let me see what I can do… do you have an idea of what you’d want to learn?
Hi Gerald, excellent video, i have a little question, we execute the commands from the xaml side of our view, but its a violation if we do it from code-behind? Let me explain, I need to populate a ListView when the view is loaded and i achieved this by:
// C# code
MyViewModel vm = (MyViewModel)BindingContext;
vm.PopulateListViewCommand.Execute(null);
//
Using this in the code behind, its a MVVM violation?
Basically everything you do in your code-behind is a violation if you strictly want to follow it
Nice video as always, love watching them as they are short and to the point ... but can you make some video about MVVM frameworks (CrosMVVM, LightMVVM, FreshMVVM ...) I think some of them are discontinued and will not be maintained anymore .. like LightMVVM .. some pros and cons (this one is lightest and fastest but doesn't have this or that or CrossMVVM has it all but its robust)
Thanks Matija! I will look into that! Note that MvvmLight (I assume you mean :)) is no longer maintained and you should now use CommunityToolkit.Mvvm which is the successor!
Great video! A video about binding will be nice
I already have a playlist about some of that, does that cover your questions? ua-cam.com/play/PLfbOp004UaYWOuVUuEtGlpkDIC1houhn_.html
Amazing as always... bravo bravo... gonna try this later on m1 mac mini
Thanks! Let me know how that goes!
@@jfversluis sure, will do
Is that “helper method” a requirement or something that’s only needed in certain cases?
Which helper method is that?
@@jfversluis does the PropertyChanged event implementaton get invoked automatically and change the XAML or is invoking it manually as you have done in the OnPropertyChanged method required?
@@MrRobravens Ah you will need that, but I think it's there by default on all the Xamarin.Forms controls. It will be invoked automatically by the XAML binding engine indeed
@@jfversluis perfect thank you!
Hi Gerald. I specify the ViewModel in the xaml using a section. Intellisense works great then. But if I initialize the binding context in the page constructor (because I have to pass some parameters) the ViewModel gets initialized twice, once without and once with the parameter(s). Is there a way to prevent this? Or doing it a better way?
You can pass parameters through XAML, have a look at this post: xamgirl.com/xaml-tips-and-tricks/ not pretty, but you can :)
@@jfversluis I don't think this is what mean. I open a new page for a tapped product or something with new Page(productid). In the codebehind of this page I set de BindingContext to new ViewModel(productId) in the constructor of that page that accepts this parameter. So there are 2 constructors in this viewmodel, one without and one with a parameter. This viewmodel is referenced in the xaml so intellisense works correct. But when this page in opened the reference in the xaml causes the viewmodel te be initialized with a call to the default constructor and the call to new ViewModel(id) in the page codebehind causes the ViewModel to be initialized again with the call to de contructor accepting that parameter. It works, but costs time and extra resources. What is the 'normal' way to do this? Last solution a came up with is: because the reference in the xaml initializes the viewmodel already, so in the page codebehind I only set a property of the BindingContext to the productId. (Or call a method if it needs te be async)
@@KeesAlderliesten There is a lot in here 😄 not sure if UA-cam comments is the best way to answer this. I think you might want to look at compiled bindings which still gives you IntelliSense but doesn't create an instance of your view model: docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/data-binding/compiled-bindings
I think when I used to build this I would just have 1 constructor and pass in a -1 or null or something whenever I needed something new. But that's mostly dependant on preference and requirements.
@@jfversluis Thanks! :-)
@@KeesAlderliesten No problem at all! Send me an email or something if you still want to know something :)
Hi is it possible to inject the view model into the code-behind. Im using Autofac, but Im having trouble cause it seems that WPF only calls the default constructor of the code-behind and thus my injected types doesn't get injected.
Hm not sure about WPF to be honest...
If I have a single button to push a new Navigation page, should it's function be included in the Model class or simply implement the OnClick function in code-behind?
If you want to do it "right" everything should be in the model :)
10:45 Yes please!!
Coming today! Stay tuned!
I would like to know the best way to implement business logic in MVVM pattern. This is because in the nearest future I migrate to MAUI.
I think that would be a hard topic. That depends very much on what you’re trying to do :)
Great video. If you can make a video about MVVM basics!!!
I'm planning to do something around that. Stay tuned!
Hi Gerald I'm trying to use command for activity indicator Command Visibility = true -> Task -> Visibility = false, is it posible?
That should definitely be possible!
@Gerald Versluis Thanks for answer, the actual fact is that keep in the first on property changed command, looking for a way to recall
I have solved this issue, without using command, but activating property in the right moment, thanks for the video that was the base to achieve use of activity indicator at demmand
I love MVVM pattern ♥.....(btw) let you know, I finally got my macbook pro, I haven't installed anything yet but when I set it ready, I'll let you know about my experience
Ooh awesome! Please do!
Can you clarify something? Can maui work under net core on desktop like avalonia does?
Hm not sure what you mean? It will use .NET 6, which is the continuation of .NET Core, so yeah it should be able to run on a desktop with it's own runtime version
Hello Gerald, how can I make a page the "main page" while running the app?
Assign a new page to the Application.Current.MainPage property :)
@@jfversluis Ohh okay. ANd in my code what do I do?
I guess something like; Application.Current.MainPage = new MyPage();
@@jfversluis okay! Thank you.
gr8 vid please keep going
Thanks, will do! Anything you'd like to see in regard to MVVM?
@@jfversluis if u can in the future make like a todo list app CRUD operations and UI made with MVVM but without MVVM Frameworks or packages to be albe to understand how things works and tnx a lottt
windows forms uses Code-Behind right ?
It does! But I don’t think WinForms has the means to support MVVM built-in, but not 100% sure on this
Osum..pls show implemention of barcode stiker printing through bluetooth printer in xamarin.
I'm sorry, I don't have such a printer around so I can't make that video :)
Maybe this helps: www.xamboy.com/2020/04/20/bluetooth-printing-in-xamarin-forms-using-shiny/
@@jfversluis thanks. but it's printing only string text,not barcode..
Great
Glad it was helpful to you!
I would use ICommand not Command, especially because your Command implementation might not be a Command instance
Good! More advanced stuff for a next video ;)
El único que pudo explicar por qué solo se almacenaba el valor en la propiedad, pero no cambiaba el valor en el objeto.