Models - WPF MVVM TUTORIAL #1
Ғылым және технология
Learn about the model layer of MVVM, which contains the core domain logic of the application. I also go through the setup in Visual Studio and introduce the domain for the application.
In this series, I demonstrate all the key components of a WPF MVVM application. This series will lay the foundations for building your own application.
TIMESTAMPS:
0:00 - Introduction
0:32 - Domain Model Introduction
1:32 - Project Setup
2:07 - Scaffolding the Model
7:16 - Satisfying Use Cases
12:23 - Testing
13:30 - Overriding == Operator
14:45 - Conclusion
SOURCE CODE: github.com/SingletonSean/rese...
💎 Become a Member: / @singletonsean
🏠 Discord: / discord
🐤 Twitter: / singletonsean_
🏆 Donate: www.paypal.com/donate?hosted_...
✉️ Email: youtube@singletonsean.com
Пікірлер: 127
This is the best place to learn MVVM. Thank you for taking you time to share this with the community.
One of the best videos to learn MVVM, with great explanations with clear, non-redundant language. Thank you so much for making this.
At first glance this kind of Model is overwhelmingly complicated, but thus fulfill the subject very thoroughly. Definitely we should learn from you Sean! Thanks!
I am a new developer diving into WPF. I watched this tutorial from start to finish and found it extremely helpful. The speaker took great care in explaining each paragraph in the video, covering everything from building functions from scratch to refactoring and optimization. I highly recommend this video to developers venturing into WPF and utilizing the MVVM framework. It's definitely worth watching from beginning to end.
Straight to the code with a good and clean example project. Maybe it’s a bit too fast for absolute beginners but I loved it
@magmyr
Жыл бұрын
I agree. For someone that wants to follow the steps, I need to stop the video all the time so I can follow along.
I have never seen a tutorial video so concise and so on point on any topic. You are my new favourite tutor. I`m baffled on all the stuff you went into, I`ll be returning to this video to get ideas when building models for any application. That was trully aweome.
@SingletonSean
2 жыл бұрын
Thanks Antonio, I'm so glad to hear this was helpful!!
@HamedAlRasni
2 жыл бұрын
@@SingletonSean Thank you, my best teacher, I learned a lot from you about MVVM. Thank you for your effort. I would like to be a member of the channel, but my subscribe icon does not appear, I am from Yemen, I do not know if you have already defined your audience, and I have another question: \\\ Do you have a lesson that explains Using all the package functions (MVVMEssentials) + Dependency injection as I explained in the Full Stack WPF MVVM series..?? ///... Thanks for your great effort .
Excellent! I picked up so many things from this first video, I can't wait for all the cool stuff I'll know by the end of the course.
Your tutorials about wpf are pure gold
@SingletonSean
2 жыл бұрын
Thank you H P, glad this is helpful!
Man, nice work! I am building a small wpf app and this is just what I needed!
An amazing tutorial. Thanks for taking your time to do this. Really appriciate it.
Gracias Mister SingletonSean....es Oro Puro este tutorial.....Saludos de los Andes Peruanos
This made my day..God bless you sir..You giving me the confidence to believe in myself and look for work after 3 years!!
@SingletonSean
2 жыл бұрын
That's great to hear fellow Sean! Confidence is so key 🔑
You've read mymind!!! This was just what I needed!! Thank you so much!!
@SingletonSean
2 жыл бұрын
Glad this is helpful, Christhian!
A very good teacher. You taught well with a clear and simplified explanation.
@SingletonSean
Жыл бұрын
Thank you, Kopil!
Thank you very much! I've been doing programming for over a year now, but I always had the feeling that I couldn't build anything myself. You showed me how simple things can interact with each other and opened up a new vision for me in development.
@SingletonSean
5 ай бұрын
That is wonderful to hear, glad this has inspired you!! 🚀
Granted I'm not exactly a beginner but I actually do like the speed. I tend to just watch videos like these without following along and then implement the concepts in my projects at a later time. I disagree with the people who say it's bad I think it's just an intermediate level tutorial that assumes a certain level of familiarity. For those with problems I would remind you that MVVC and design patterns in general tend to be more advanced programming concepts. There is no shame in wanting a slower format that goes into more details but for people who are just looking to pick up MVVC and little else I believe this is actually a pretty good tutorial which is why it's the first result when searching for such a thing.
Great video! Keep up the good work!
Best MVVM Tutorial out there
@SingletonSean
2 жыл бұрын
Thanks Icse, glad this is helpful!
its not just a beginner tutorial. an intermediate one. but a good sprint will be handy for beginners
Hey man, this is a really good style of video. Gonna walk thru it and check out your others...
Excelente mister SingletonSean....saludos de los andes peruanos
This is top-notch... Thank you...
Amazing work
Mate we're currently about to do mvvm in college and want to learn a lil earlier thank you soo much
@SingletonSean
2 жыл бұрын
That's awesome ZANE! I used to love getting a head start in college, it would always help a ton.
this channel have the best tutorials for c#
@SingletonSean
Жыл бұрын
Thanks Bl1c_sana, glad these tutorials are helpful! Nice custom emojis 🎉
That you for your videos they have been a big help. But I did want to point out for anyone running into this...conflict needs to check if reservation starttime is between starttime and endtime...same goes for reservation endtime. If you only check then conflict can return true and there not actually be a conflict.
Well put together video.
10:46 Why in my case it didn't add the parameters to the existing constructor, and instead the menu option creates a new one?
When overriding OnStartup, it throws no errors if there is only base.OnStartup(e); . However, as soon as I try to add any more code to the override, there is an error. It says that "base" is an invalid token.
Soo gooood! that's all I can say :)
HI, great ressource, what version of c# and .NET freamework you are using in this project?
Sean, I like the tutorial. It's one that actually builds a complete example. You move fast. This prompted me to study my snippets and shortcuts again. I am uable to build the project on my system. Visual Studio 2017. I get this error and some other realated errors: TargetFramework value 'net5.0-windows' was not recognized... Can you suggest a fix for this?
You touch upon UML and Use Cases, which is excellent as code follows design. However I've never had to pause so much in a tutorial. You don't tell us what the shortcuts for autogenerating the code are, although I did figure out "ctor-tab-tab". When you did the constructors for the Exception and at least three were autogenerated, at that point I'm like "WTF?".
@MaxiJabase
2 жыл бұрын
The thing is, this is not a tutorial on those kind of things. If you're wishing to learn MVVM is because you've already gone through a decent chunk of work related to C# and programming in general to be seeking improvement in the design-pattern area, which is far gone past the VS navigation/shortcut perks. I personally appreciate when the tutorial doesn't branch away from the topic explaining little details of everything, because when you're learning something new it's important to keep that momentum that makes you flow through new concepts and ideas efficiently, and I think that momentum is fragile and must be kept at all costs.
hi, can you help me a bit with my project? I must split Logig and UI but i dont know how to da it... It would be mega great!
Just to be clear, any properties that should be editable should have setters as well, rigth? Like if you could edit a reservation, the start and end dates should have setters?
I'm a beginner, I would like to do something when I close the window, at the beginning I used the OnClosedWindow fonction in the code behind but I don't think it's a very good way to do that. I want to do the function in my mainViewModel. Someone can help?
There is a problem of hashcode i try to install the package but not work.
This is a good tutorial but some of the Visual Studio code generation magic is skiped over too fast to understand what he's actually doing.
@user-rf4nt2ge4f
Жыл бұрын
0:10
Hi this might be a stupid question, but at around 5:50 I don't understand why we need to override the equals operator. Why can't we just use the normal Equals for the object? Thanks for the tutorial.
@shinyshark2247
2 жыл бұрын
Yeah I have the same thought. I don't really understand why we're throwing away all the functionality that the method offers and narrowing it down to just what our usecase would be.
This is definitely for intermediate people comfortable with cs syntax…which I barely am, but great tutorial
how can i use openfiledialog mvvm?
Hi i dn't ve to tell u this but i want to : i ve watched a lot a wpf's MVVC teacher but you re just the king of learning without any doubt. Thank you for your time& efforts. I have a wpf project about booking a workspace/dockingstation/work material... for employees .. the point is that i ve to group by room coz in the room it could be more than an employer , wht u think which models i ve to include in my models folder ?
You are saving my IB diploma haha tysm
@SingletonSean
2 жыл бұрын
Hahah glad to hear, Jupiguy! Shoutout to you for seeking out content to enhance your learning
I'm thankful for the fact that you're sharing your knowledge with us, but if I may.. Lots of us would benefit from a more relaxed pace and not seeing you flip from one tab into another while you continue explaining. I'm saying this because I'm attempting to follow along with you and find myself not only pausing to keep up, but also having to rewind to actually grasp what you're saying. A steady pace for the same content you're already producing without jumping back and forth between classes to illustrate what you're trying to say would probably attract a lot more viewers. :)
@klondikexx2831
Жыл бұрын
I agre with this. Its kinda very hard to follow along
really cool presentation of WPF even if it is a little fast for me. Btw, one question it loook like a lot of logic is implemented at Model level. Why not having this logic in upper layer ?
your voice and speed of speaking here is so comfortable to listen to and make watching great, not boring and hard to focus
@SingletonSean
Жыл бұрын
Glad you enjoyed the pace, thanks for the feedback ren yeh!
Thaaaaaanks! Don't have no money yet. Will donate in future.
thanks!
How do you make changes so fast? Like at around 8:50 you change = new Dictionary to List instantaneously.
@SingletonSean
10 ай бұрын
It looks like it was just editing in order to make myself look like a speedy 10x developer 😓
@ElCidPhysics90
10 ай бұрын
@@SingletonSean lol. I keep saying how in the world did he do that so fast? I want the shortcut lol
Maybe if you're unable to get the HashCode, declaring an internal class of HashCode may help.
Hi, i'm really grateful for your courses. And a question is how can i be member to see this playlist which is member only ...???? (I'm subscribed you ...)
@mcnets
2 жыл бұрын
There is a link in the description of the video.
@SingletonSean
2 жыл бұрын
Thanks Sajad! Along with mcnets comment, I also describe it a bit in this video: kzread.info/dash/bejne/aq6L29GpgrjHh8o.html
I've watched a few Tim Corey videos, and he is soooooo slow! These are picking up the pace, and I can still understand what you are saying (not English from India).
@SingletonSean
Жыл бұрын
Glad this pace was good jp2code! Pace seems to be subjective - I get tons of people complaining about my pace too hahaha. I definitely have room for improvement still 😁
The validation logic has issues. Validation first rule is to check if existing reservation is on same guest as incoming reservation. You either do that by looping through the filtered collection (get reservationsbyUser) or add checking guest name first in the conflict method
So when testing 13:09 reservations ResultView shows: Empty "Enumeration yielded no result". Anyone else got this problem/solution? My code is pretty much the same
@Zbaz10an
2 жыл бұрын
Yeah I had the exact same problem, here is the issue: In the Reservation folder you need to use the "username" parameter like this: "public Reservation(RoomID roomID, string username, DateTime startTime, DateTime endTime) { Username = username; RoomID = roomID; StartTime = startTime; EndTime = endTime; }"
how did you generated the constructors at 10:30 ?
@SingletonSean
2 жыл бұрын
I did a "CTRL + period" with my cursor after "Exception", and that brought up the context menu where I selected to generate all constructors
Hi Sean! I've got a couple 'off topic' questions about your videos. Where's the best place to ask them?
@SingletonSean
2 жыл бұрын
Email is good (which I see you've already sent to, hahah)
@yazoncui625
2 жыл бұрын
@@SingletonSean Can I know your email address?
is there a shortcut for documenting the code because it was fast :) ?
@SingletonSean
2 жыл бұрын
Try typing '///' on top of a method/property/class :)
@Gholamalih
2 жыл бұрын
@@SingletonSean I thought you created all these documents with just one shortcut key.
thought i could catch up but it's too much for beginner like me. will definitely come back after i am more comfortable with basic coding.
@SingletonSean, want to hear the funny side of it? Play this video back at 0.5X speed from about 3:00 minutes. It sounds dope man. I wanted to hear what you said because you were going fast, so I played it back at 0.5X. Quite funny. Sounds like you on something haha.
@SingletonSean
Жыл бұрын
Definitely! 😄 although I would argue that most people (excluding folks like Ben Shapiro) sound pretty whack on 0.5x speed
🎯 Key points for quick navigation: 00:00 *🏨 Understanding MVVM architecture for WPF applications* - MVVM architecture separates the view layer into models (M), views (V), and view models (VM) - Exploring the concept of models and how domain logic is encapsulated within them - Creating classes for a hotel, reservation book, reservation, and room id to represent the domain model 02:07 *🛠️ Implementing model functionality* - Organizing classes into folders within the project structure - Defining methods within the model layer to interact with the domain logic - Handling reservation conflicts and implementing exception handling within the model layer 08:13 *📝 Refining model functionality for user interactions* - Introducing user identification within the reservation class - Opting for a list data structure over a dictionary for simplicity and ease of use - Defining methods in the model layer to support user actions such as viewing and making reservations Made with HARPA AI
4:55 Readonly models (this was ref in Services tutorial)
Not a fan of using VS class diagrams?
@SingletonSean
2 жыл бұрын
I haven't really used them yet, s not currently/yet. They look nice, I will have to check them out!
hi, i have a project in mind and i'm developing with c#. are you interested to partecipate?
most MVVM tutorials shove all the domain logic in the VM. Its rare to see some proper model design.
Everywhere I look people say you need a framework for MVVM in .NET, but here you show that you really don't, what am I missing? Is it just the dependency injection capability that these people mean? Why use MVVM framework when you can not to?
@SingletonSean
2 жыл бұрын
I feel the same way! I think the big thing with the MVVM frameworks is navigation support, as well as DI like you mentioned. I'd have to try out a framework to really have an opinion though.
3:10
Wouldn’t it be better if RoomId is a struct
@SingletonSean
2 жыл бұрын
I think it would have been possible to just use a struct, which would've been nice for skipping the equality override. Good point!
Hi, I would like to join to your channel is it possible make monthly payment with PayPal, thanks.
@SingletonSean
Жыл бұрын
Hi Bozo, it is possible! KZread supports PayPal as a payment method. Let me know if you have any issues (I work at PayPal).
@bozoskopljakovic5508
Жыл бұрын
@@SingletonSean When I click Join I got Complete your purchase where card number is required I do not see PayPal option.
This was presented way too fast. Maybe this would be useful to people who already know the information and just need a refresher but for those who are trying to learn... forget it. I got some useful information out of this but I felt like I was missing a lot of context.
Hi, nobody here use mvvm toolkit?
You jump around way TOO much and I am not sure sometime where things are being added ... also shortening the typing, for say comment but there are others, throw off where we are. I have been spending more time rewinding than listening
Stay away from this tutorial unless you are very good at C# development already. First 5 videos are very good for understanding basic MVVM concept but after that its complete mess for begginers. This guy is very skilled and clever and his backend is rather over complicated for functionality than simple for tutorial. Also there are no clear explanations and lot of references to different videos.
@SingletonSean
10 ай бұрын
Hey I appreciate the feedback! I think your points are pretty realistic - this tutorial could be better. I hope people absorb the approach I take rather than copying the code, and then use that to influence their own MVVM style. I also blame WPF for being a tricky framework and sometimes needing unnecessarily clever solutions for things 😄 I think there is still a lot of value in this series, but I definitely want to re-think some things, listen to feedback, and create a better tutorial in the future!
Your material is good, but the pace is way to fast. Slow down, and then slow down some more :-)
@SingletonSean
Жыл бұрын
Thanks for the feedback Klondike! It is a bit too fast. I've secretly taken a break from recording new content for the past 3 months in order to work on pace, quality, etc. 👀
Your Example is very complicated
Slow down, buddy
Ever heard the term' Dazzle them with brilliance or Baffle them with BS'. Slow it down if you really are trying to teach and not just SHOW OFF. The work is good but useless if the people trying to learn it spend more time rewinding then learning.
Bring back dislikes @youtube
Worse tutorial yet. The only people who could follow along at this break neck speed without detailed explanations probably don’t need this tutorial in the first place
@SingletonSean
10 ай бұрын
Yes I need to go slower 😂 I have learned this over the years, especially from the feedback I've gotten on this tutorial. I'm hoping this is still valuable given the lack of WPF resources out there. Can always reduce playback speed or re-watch parts if it's too fast, although that is not ideal for viewers. I also hope people are more focused on the approach I take, and not the specific code I write. But I understand everyone learns differently! I really just need to own up to and create a slower WPF tutorial because I get a comment like this everyday on this series 😂
You edited out the name of the project....:( Also did you dub this after editing out time? You owe me 14 ish minutes of my life back because this literally had 45 seconds of actual MVVM talk in it. If college courses were taught like this it would require 200 years to graduate. Good information...bad format. With all the extra crap the viewer forgets the 45 seconds of relevant information.
@SingletonSean
2 жыл бұрын
Thanks for the feedback Buddy! I'm not sure what you mean by editing out time and editing out the name of the project. Based on your other comments, I'm sorry this series isn't living up to your expectations.
@buddysnackit1758
2 жыл бұрын
@@SingletonSean In the video I was watching what you typed in for the project name and it looks like frames were removed. Your presentation skills are good but people read your title and expect to learn about MVVM and how to implement it using C# and xaml. Th vast majority of the content however is editing non-topic items.
Presented way too fast for a tutorial on introducing MVVM . I quickly got loss. This type of delivery does little to help the developer community.
@SingletonSean
Жыл бұрын
Hey Tom, thanks for the feedback. I'm sorry this wasn't helpful to you. I understand your perspective though. Honestly, I've been doing this channel for a few years and feel like I haven't quite found the right flow and style. I've finally spent the past few weeks looking for ways to improve. Hoping 2023 will be better, and I hope you have a great new year!
not helpful for absolute beginners
bs
@SingletonSean
2 жыл бұрын
"beautifully said"?
Very important to note that reservation.StartTime = StartTime , works but reservation.StartTime >= StartTime && reservation.EndTime