WPF MVVM Tutorial: Build An App with Data Binding and Commands

Поделиться
HTML-код
  • Опубликовано: 25 апр 2023
  • In this video, you will learn how to use the MVVM pattern in WPF to create a app. MVVM stands for Model-View-ViewModel and it is a design pattern that helps you separate the presentation layer from the business logic and data layer of your application. You will learn how to use data binding, commands, in WPF to make your code more maintainable and testable. This video is suitable for beginners who have some basic knowledge of C# and WPF.
    Source Code :
    github.com/TacticDevGit/Recor...
  • НаукаНаука

Комментарии • 68

  • @wawandharmawan2441
    @wawandharmawan2441 4 месяца назад +3

    I just learned C# and WPF about a month ago, and this video really helps me understand how MVVM works. Thank you! 👍

  • @philsnewaddress
    @philsnewaddress 11 месяцев назад +7

    Last year I inherited a 600 dll MVVM project with poor documentation. This video has brought me so much clarity. I've been programming C# for 15 years on and off, but that has been 90% winforms and 10% MVC and some WPF, but not true MVVM. In fact this video reminds me of a tutorial I read in 1995 for C++ MFC. That "scribble" tutorial provided just the foundations of the framework and I was then able to write C++ MFC applications which I'm still doing at work nearly 30 years later. This video, I feel, covers the MVVM foundations in much the same way. Thankyou.

    • @TacticDevs
      @TacticDevs  11 месяцев назад +1

      I'm glad to hear that the video has brought you clarity and has been helpful for understanding MVVM, It sounds like you have a strong background in C#, with experience in WinForms, MVC, speaking of C++,I was just done writing and compiling a bios flashing tool just like a day ago😅 its was exhausting( C++ is too low-Level) ,

    • @philsnewaddress
      @philsnewaddress 11 месяцев назад +1

      @@TacticDevs I've never written a true kernel mode device driver but I did write a fair amount of direct windows calls years ago. I also wrote a 3D game once (1993, no libraries) which mixed assembly and C. I still prefer native over managed, but I can feel the pull of intellitype leading me towards patterns in C#.

  • @racheLove555
    @racheLove555 11 месяцев назад +1

    Thank you so much for this video! after a couple of videos watching, and misunderstanding the concept, you were doing it - simply and gently! I'm happy to find your excellent video. thanks.

  • @angelenriquechavezponce1629
    @angelenriquechavezponce1629 9 месяцев назад +2

    Absolutely amazing, well paced, straightforward and includes some tips and tricks here and there. You've ganiened another sub and my respect 🤝

  • @xiaasafoon9427
    @xiaasafoon9427 Год назад +1

    This video was great; it was easy to understand and clearly explained.

  • @yunussurchy6359
    @yunussurchy6359 9 месяцев назад +1

    I decided to learn windows development using wpf, was searching and your channel popped up. i really love your videos and explanations. it would be really nice if you starting a series for newbies like me.

  • @HemantChauhanMsc
    @HemantChauhanMsc 5 месяцев назад

    Thank you very much for this video, I gone through so many videos to understand MVVM but this is the best one.

  • @niangel2704
    @niangel2704 9 месяцев назад

    Congrats and thanx for this lovely video!! I've been coding using WinForms so far and I find it a bit difficult to adapt to the WPF. I was able to follow along and understand and justify your steps but I am afraid I dont feel comfortable to apply them to my appsm as yet. I will keep up climbing up the steep curve of learning WPF as I find it quite interesting!! Thanx again my friend!! Best regards from Greece

  • @lerax2010
    @lerax2010 4 дня назад

    thank you! now I finaly have an understandingthe the pattern realization

  • @pierrestcergues
    @pierrestcergues 5 месяцев назад

    Thanks for all your great tutorials !

  • @meterdn
    @meterdn 10 месяцев назад

    i love how chill you are

  • @RT-fi7rb
    @RT-fi7rb 7 месяцев назад

    Really Great Explanation. Thank you!!

  • @Viezieg
    @Viezieg 4 месяца назад

    very helpful and easy to follow. thank you very much !

  • @nicolasfok5661
    @nicolasfok5661 8 месяцев назад

    Man !, you are truly a lifesaver !

  • @sond.v.6816
    @sond.v.6816 Год назад

    This video was great. Thank so much

  • @user-qr8pl9vp1x
    @user-qr8pl9vp1x 8 месяцев назад

    Thank you very much for this tutorial.

  • @shobhamahadev118
    @shobhamahadev118 4 месяца назад

    Peace voice, it suits to one of my friend's voice. Nice video thankyou.

  • @RoberBot
    @RoberBot 4 месяца назад

    Really nice tutorial, good job.

  • @harilalmn
    @harilalmn 3 месяца назад

    Very helpful... Thanks!

  • @BeeryDorin
    @BeeryDorin 4 месяца назад

    practical and enriching, thnx!

  • @arunkumar-ru2zl
    @arunkumar-ru2zl Год назад

    tq u very much bro for posting this video

  • @SrimalSamarasooriya
    @SrimalSamarasooriya Год назад +3

    Cool video. Thanks for this. Small request. Can you do this with mvvm toolkit?

  • @ferenc3460
    @ferenc3460 Год назад

    Hi! Thanks for your video. I have a question. So I have a window with a listbox filled with objects in it. And I move these object from one list to another in the viewmodel. But is it possible to move these object on the UI with animation using only the viewmodel anyhow?

  • @tommcmeekin1
    @tommcmeekin1 6 месяцев назад +1

    Great video, could you do a part 2 where you add ef core and a sqlite db? Would love to see that 😀

  • @JitendraKumar-fo2wj
    @JitendraKumar-fo2wj 29 дней назад

    Thanks ! Great video, just an extended question on the same, how would you implement the tab functionality on the search box? After searching the name, I want to tab to the first element and highlight the first row. TIA

  • @okitkin
    @okitkin 5 месяцев назад

    Thank you very much !!!))

  • @janjanlara2502
    @janjanlara2502 Год назад

    hi thank you for this video, can you make a small project tutorial using this MVVM WPF c#?

  • @nyendwa
    @nyendwa Год назад

    Hi Jamie, I finally took time to go through this application and its platinum gold, kindly take time to respond to questions on the channel, it makes it fire. My question is, I noticed when we add a new user say, Jamie, email et al, once we close the application and open it again we no longer have Jamie as a user. Is there a way we can add Jamie in the hard-coded observable property from the user interface?
    If yes, could you make a short video on that?
    if not, can we then use the CRUD property using the entity framework? I hope to hear from you and you respond to my other comments.

    • @TacticDevs
      @TacticDevs  Год назад

      Hi how are you doing, we cannot persistently add a user to the observable collection because that memory is only used at runtime when we shut down the application that memory is released,when the application runs again it pulls the names from the observable collection that is hard coded in the application,however we can use other means of persistent storage like a database or a file etc. We can definitely use entity framework to manipulate data in a persistent manner using a database

  • @belgabad
    @belgabad 2 месяца назад

    Barely starting MVVM WPF and I can see some flaws in what is explained :
    - The ViewModel should not reference a View at all, as I understood it opening a new windows in a MVVM-friendly manner is hard but it shouldn't be dealt with like that
    - Using an event handler in the code behind is an unwanted simplification. Wether the View's code-behind should or not have anything is a discussion but the main point is that it shouldn't contain any logic, but the filtering is done entirely by the View (which also mean you can't unit-test it). The logic should be in the ViewModel, maybe through a property binded in two-way/one way to source and the filtering is called in the setter of the property

  • @sathsarasoysa
    @sathsarasoysa 11 месяцев назад

    I want to edit and delete the data on the desktop. The Edit button must show the details of the selected student, and the user must be able to edit them. The delete button should delete the selected Data row. Can you please help me with this?

  • @DonaldFranciszekTusk
    @DonaldFranciszekTusk Год назад +2

    Hi and thank You for great, peaceful explanation.
    I have questions for RelayCommand class.
    Why do you use Predicate? Shouldn't we use Func?
    And what about CanExecuteChanged?

    • @TacticDevs
      @TacticDevs  11 месяцев назад

      because the Predicate returns a boolean (true or false) , the returned boolean determines whether or not the command is enabled or disable , the predicate allows to define some custom logic that returns true of false

  • @TechKingdomChannel
    @TechKingdomChannel Год назад

    i clicked Like Even Before getting 1 minute.

  • @fabriziocivati8237
    @fabriziocivati8237 Год назад +2

    Graet video but i have a question, why the filter was not included in MainVindowViewModel?

    • @nyendwa
      @nyendwa Год назад

      We did not have the MainWindowViewModel class in this project, basically it is in the MainWindowViewModel except we deleted it when starting the project and added a Xaml window called "Main.Xmal" where the filter method was placed.

  • @MattCantSpeakIt
    @MattCantSpeakIt 10 месяцев назад +2

    Is it really okay to show a window from the viewModel? I though view models should be able to be unit tested and not depend on UI stuff like showing windows?

    • @RoberBot
      @RoberBot 4 месяца назад

      I think its better to show windows from the app.xaml.cpp usin g the OnStartUp method if i remember correctly
      That's also the place where we create the viewmodels and everything else that might be needed like a databaseclass and then pass it to the viewmodels that might need it.

  • @niangel2704
    @niangel2704 8 месяцев назад +1

    Can you do a new video with WPF, windows mvvm community toolkit and efcore to sqlite?!
    This should be a piece of cake for you...
    Please enlighten us😊

    • @Dan-Levi
      @Dan-Levi 5 месяцев назад

      +1 on this. Been struggling to source a good tutorial on CommunityToolkit.Mvvm for WPF, with navigation.

  • @kishiforyou
    @kishiforyou 2 месяца назад

    in what scenario do we need to use icomamnd , you used command to popup a window and add a content to he list , but you did not implemented for filter any specific reason for that , kindly explain me indetail

    • @TacticDevs
      @TacticDevs  2 месяца назад +1

      when we stronlyg follow the mvvm pattern we must use icomamnd, the reason i didnt use it for the filter is i wanted to keep the video under 50 minutes in the future i will make a seperate video on that

  • @nyendwa
    @nyendwa Год назад +1

    Great audio. The previous one wasn't clear.

  • @jreffjeff7909
    @jreffjeff7909 Год назад +1

    My VS doesnt have the option for any of this pls help

    • @RoberBot
      @RoberBot 4 месяца назад

      Get visual studio community, vscode isn't the best for C#

  • @niangel2704
    @niangel2704 8 месяцев назад

    Hello guys,
    Does anyone know how to enable/disable the Add button of the AddUser dialog according to the contents of the textboxes? if even one of the textboxes is empty then should be disabled else enabled
    Do we need another RelayCommand or event or what?

    • @TacticDevs
      @TacticDevs  8 месяцев назад +1

      you can do that by adding some logic to canAddUser method of the adduser Command the method should return true if there is content else return false, this will automaticlly disable the adduser button when there is no content

    • @TacticDevs
      @TacticDevs  8 месяцев назад +1

      check 28:40

    • @niangel2704
      @niangel2704 7 месяцев назад

      @@TacticDevs this logic is what I am looking for!!
      Do you mean to add a _isChanged property (in the viewmodel or in the model itself)?
      And then how would the _isChanged be informed about changes in any of the User properties contents?
      via NotifyPropertyChangedFor or what? Thanx in advance for your time.

    • @TacticDevs
      @TacticDevs  7 месяцев назад +1

      @@niangel2704 I’ll make a video on that soon over the weekend

    • @niangel2704
      @niangel2704 7 месяцев назад

      @@TacticDevs you are a star!! I look forward to it

  • @webdevfs9361
    @webdevfs9361 8 месяцев назад

    Your starting project structure and files are very confusing. i was trying to follow along but got lost with the styles.

  • @danilatravkov1474
    @danilatravkov1474 26 дней назад

    I wonder why UserManager class is in Models folder and not it ViewModel folder.... :D

    • @TacticDevs
      @TacticDevs  26 дней назад

      The ViewModel folder usually contains classes that serve as databinding objects for the views (they store information to be display in the view) Since UserManager deals with managing user and not for storing information to dispaly in the view.its best to put place it in the models folder

  • @msdevg
    @msdevg 5 месяцев назад

    Hello Thank for your video. Can you share this code. It will be very helpful.

    • @TacticDevs
      @TacticDevs  5 месяцев назад

      check the video description

    • @msdevg
      @msdevg 5 месяцев назад

      Thanks

  • @scramjet4610
    @scramjet4610 11 месяцев назад +4

    Complicated code (ObservableCollection, complex ListView with styles, etc.) interferes with trying to learn the MVVM. The basic code should be a lot simpler so the viewer can focus on the MVVM. If viewer can easily follow this example code, then they probably already know MVVM.

    • @RoberBot
      @RoberBot 4 месяца назад

      This wasn't a complex example and observablecollection is just a list that can update the ui.

    • @scramjet4610
      @scramjet4610 4 месяца назад +1

      @@RoberBot It's complex if learning this coming from an embedded C background.

    • @RoberBot
      @RoberBot 4 месяца назад

      @@scramjet4610 Then yes it might be, but this isn't a Wpf beginner tutorial, this is an mvvm tutorial, you should first watch a Wpf beginner tutorial and make a small thing then come and watch this, you don't really need the mvvm pattern to make an app, you need mvvm to make a testable and maintainable app, I've build 3 wpf apps until I found out about mvvm

  • @uuuborovi
    @uuuborovi Месяц назад +1

    ничо не понял

  • @mohammedkaka5558
    @mohammedkaka5558 7 месяцев назад +5

    The issue with your tutorial is it is totally not friendly for beginners, for example, a new user does not know how to design the windows and setup the project files, i think you should address this in your tutorials,

    • @RoberBot
      @RoberBot 4 месяца назад +4

      I don't think this is a beginner video, you should watch a Wpf beginner tutorial first.

    • @manbirjudge8415
      @manbirjudge8415 Месяц назад

      Its you problem. This video is definitely not meant for a beginner.