C# WPF - Relay/Delegate Commands [Part 2]

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ม.ค. 2025

ความคิดเห็น • 67

  • @gard2054
    @gard2054 4 หลายเดือนก่อน

    7 years later, and this is still hands down the best explanation out there

  • @shaikhzoyeb
    @shaikhzoyeb 6 ปีที่แล้ว +6

    thanks for explaining beautifully , WPF is pain in the A** for beginner however after watching your tutorial i have got an idea how really binding and generic command binding works

  • @misters6451
    @misters6451 6 ปีที่แล้ว +4

    Thank you man! I learned more about WPF from this video than a few days of reading some articles.

    • @uchitesting
      @uchitesting 4 ปีที่แล้ว

      Same here. It's relieving.

  • @Vitorgasparete
    @Vitorgasparete 2 ปีที่แล้ว

    Thanks very much! So Simple video thats helps me a lot. Another point is Im Brazilian and your english is easy to understand.

  •  4 ปีที่แล้ว +1

    Your video helped me a lot in one of my University projects.
    You're a GOD ❤️

  • @mahmoudzeort7078
    @mahmoudzeort7078 3 ปีที่แล้ว

    Excellent! the best videos explaining Icommand and commanding in WPF MVVM. Bravoooooooooo

  • @finch9668
    @finch9668 6 ปีที่แล้ว +4

    You're so good. Wish there are more tutorials ~ thx

  • @CarloJS
    @CarloJS 4 ปีที่แล้ว

    thanks for the awesome tutorial, you have gained a fan!

  • @kritikyorumer
    @kritikyorumer 2 ปีที่แล้ว +1

    So good. It is clearly, thank a lot! Man

  • @andrejlicanin2419
    @andrejlicanin2419 4 ปีที่แล้ว +6

    A suggestion: make a small diagram of what's going to happen in the video, and show it and explain before you start coding. It doesn't have to be anything special, just a bunch of squares and text, and draw some lines to show how it's going to relate. Or maybe you can do it at the end of a video when you recap.

  • @santos5882
    @santos5882 2 ปีที่แล้ว

    awesome tutorial

  • @mateuszchrupczalski4247
    @mateuszchrupczalski4247 3 ปีที่แล้ว

    Great video. Thanks for the explanation.

  • @miloszodin
    @miloszodin 7 ปีที่แล้ว +8

    As promised: even though I understand everything in this video, some questions arise unavoidably. "CommandManager" is only vaguely mentioned though it plays an important role here - as far as I understand. Adding some background to this would help people like me, know what are they looking at, and after the video what to google for. Also I've leaned that there is something like "Predicate" but not much more. I would like to know what is the benefit, how it is used and how it simplifies the solution. And about CanExecute - I wonder can it be structured as an universal solution for validating textboxes for value-binded-type (as I understand it's already a part of binding convenience) while also taking some additional parameters that expand it's capabilities (enable if: equal to 8 digits, not null or empty, only letters; and so on).

    • @uchitesting
      @uchitesting 4 ปีที่แล้ว +1

      I can agree with you. I do not know either What a Predicate exactly is and I'm still curious to know more about this CommandManager thing and I'd like to know more.
      That said, the content of the video explains enough to understand and the aforementioned would need an extra research.
      What I mean is I come here to know about ICommand/ Commands in the context of WPF and I got what I need.
      The promise of the video is fulfilled. Should you need to understand what Predicate is, you need to take any course that provide the info. I can suggest you these links:
      www.tutorialsteacher.com/csharp/csharp-action-delegate
      www.tutorialsteacher.com/csharp/csharp-predicate
      I have not found more about the CommandManager myself so I can't help on that one.
      Best Regards.

    • @juanclopgar97
      @juanclopgar97 4 ปีที่แล้ว +1

      @@uchitesting I don't know if I can help to you about Predicate delegate, or if you understand it, but I'm gonna try to explain it anyways. (Unfortunately you need a Delegate and Generic Types Background, If you want know more about that, tell me and I'm gonna try to record a video explaining that)
      a predicate is a Generic delegate type, it means that it can store a method with the next signature:
      Predicate myDelegate can store
      bool MyMethod(MyType parameter){...}
      Why Predicate exist??, well sometimes you need a common usage delegate for your applications, but most of the time that delegates have a common signature for example: void MyMethodTwo(){...}
      delegates that acept methods void, with or without parameters, the gold rule is, if exist a delegate to store your method USE IT DON'T Create one!!!!. for example, if you want store void MyMethodTwo(){...}, you can create your own delegate:
      public delegate void MyDelegateType();
      In that whay you can do this:
      MyDelegateType storage = MyMethodTwo;
      but you don't need create a new delegate type because the framework provides you Action, that allow you store your method too.
      And about the 'in' modifier in the generic type... is completly other story, and very complicated hahahahaha.
      I hope this can help you :D

  • @luisarias9682
    @luisarias9682 2 ปีที่แล้ว

    This was really helpful and got me to understand Relay Commands, Why do we check if the Action or Func are null? is that the same as checking if they are instantiated? one more question, why do we add the in the class declaration of Relay Command and what difference does it make?

  • @mr.v7103
    @mr.v7103 6 ปีที่แล้ว

    This was very educational for me.

  • @sixpetrov
    @sixpetrov 7 ปีที่แล้ว +1

    Great tutorial, thank you. Although your keyboard is rather loud. Is it mechanical?

  • @ToskersCorner
    @ToskersCorner  8 ปีที่แล้ว +14

    Did some excessive babbling in this one. Whoops! ;) Try running at 1.5x speed if you are impatient like me.

    • @crusaderzero3984
      @crusaderzero3984 7 ปีที่แล้ว +2

      Good tutorial! The only thing I can suggest is that can you higher the volume of your microphone? The voice is too low for me to hear. BTW, I still have trouble to understand how the canExecuteChange event works? What's the purpose for using add & remove ComandManager.RequerySuggested +(-)=value?

    • @Jwhite1979
      @Jwhite1979 3 ปีที่แล้ว +2

      1.5? Ha. Try .75, and I still watch it five times. Well done, friend.

    • @iancarr3923
      @iancarr3923 3 ปีที่แล้ว

      Your delivery is just right for me. Thanks

  • @CornelionSigismon
    @CornelionSigismon 6 ปีที่แล้ว

    Very well done. Congrats!

  • @Vsod565
    @Vsod565 4 ปีที่แล้ว

    Super useful video.
    Just a small suggestion: instead of passing "execute" into the ArgumentNullException, it's better to generalize by using nameof(execute)

  • @nedelcugabriel7687
    @nedelcugabriel7687 4 ปีที่แล้ว +1

    Hello! Can you give me an example of how to change views using Relay Commands?

  • @islamicuniversity8628
    @islamicuniversity8628 6 ปีที่แล้ว

    Very nice tutorial for WPF, if you make the tutorial for Prism with WPF it would be great. Thanks

  • @shivaprasadmanchala3955
    @shivaprasadmanchala3955 3 ปีที่แล้ว

    Can u give example with data grid with one checkbox column. Check all / Uncheck all. Thank you in advance

  • @hazemelamir2083
    @hazemelamir2083 6 ปีที่แล้ว

    many thanks for your valuable lessons
    can you help me and make another video on how can passing more than one commandparameter & how can we pass parameter with our method

  • @arjaymaligaya6272
    @arjaymaligaya6272 4 ปีที่แล้ว +1

    How to use relay command in asynchronous methods

  • @warr39
    @warr39 7 ปีที่แล้ว

    I did find it very useful, thank you very much!

    • @ToskersCorner
      @ToskersCorner  7 ปีที่แล้ว

      +warr39 thanks for leaving a comment! Glad i helped!

  • @juanclopgar97
    @juanclopgar97 4 ปีที่แล้ว

    I understand ALL!! (almost :p) hahaahaha great videos!!!, I've just a question, What is 'CanExecuteChanged' event for???, and most importantly, Why are you storing the subscribers to 'CommandMannager' instead create a field to store that values?.

  • @edpoitras420
    @edpoitras420 4 หลายเดือนก่อน

    Can't get the Console.WriteLine to show up in the output screen- any suggestions?

  • @GAGANDEEP901
    @GAGANDEEP901 8 ปีที่แล้ว +2

    Very helpful, Thanks man!!

    • @ToskersCorner
      @ToskersCorner  8 ปีที่แล้ว

      Awesome, it's always good to hear this. If you haven't already - there is a 5 question survey in the description I encourage people to take. It has you answer basic questions that can help me improve or hone in on the things you feel you liked/disliked about how I conducted the tutorial.
      Hope my videos continue to be helpful ;)

  • @extremex5686
    @extremex5686 5 ปีที่แล้ว +1

    I did not understand why console not worked in list control. please help me to understand this. btw Ty for this video :)

    • @rainerzufall1337
      @rainerzufall1337 5 ปีที่แล้ว

      Because the ListBox object does not have a Text property. You need to set the path to SelectedValue instead. Then it works the same.

  • @juanclopgar97
    @juanclopgar97 4 ปีที่แล้ว

    Why when I press the buttons Logic are correct (Print when they have to print), but buttons are not disabled

  • @randypenajimenez3893
    @randypenajimenez3893 5 ปีที่แล้ว

    Bro, where did you get that vs theme?

  • @shubhankjoshi7175
    @shubhankjoshi7175 5 ปีที่แล้ว

    You are a god. Thank you!

  • @franklyndejesusmejia5907
    @franklyndejesusmejia5907 6 ปีที่แล้ว

    Thank you so much!

  • @ABsazerNer
    @ABsazerNer 5 ปีที่แล้ว

    How beautiful is mvvm

  • @BoyOfTheFuture4987
    @BoyOfTheFuture4987 6 ปีที่แล้ว

    can you please explain the command manager thingy a bit more.....i am a but confused ..and how does the function canExecuteChanged gets executed if it is never called... and also the add{} and remove{} ..how do these work

    • @ToskersCorner
      @ToskersCorner  6 ปีที่แล้ว

      This has to do with the behind the scenes mechanics of WPF. From my understanding, it is tied up to your CanExecuteEvent and with the command manager the event is updated on any possible changes that could affect the can execute state. For example, changing focus of controls. If you want to investigate, just try putting a break point somewhere in the can execute event or method. You will see with command manager this is called many times for many different reasons. Some of the reasons it calls can execute can be arbitrary and irrelevant, so it may be called even when nothing has changed the can execute state. Typically in more intense applications you would use a different method that calls it ONLY when the state changes. However in smaller applications such as the example, it has little negative affect on just calling it many times for 'possible' changes. Mor info can be found here, or other simple Google searches: stackoverflow.com/questions/6634777/what-is-the-actual-task-of-canexecutechanged-and-commandmanager-requerysuggested/6635324

  • @elenaking7377
    @elenaking7377 3 ปีที่แล้ว

    Anyone know why he is inactive since 4 years?

  • @raviprasad2379
    @raviprasad2379 7 ปีที่แล้ว +4

    Bro I usually use smartphone to see TH-cam, and those who do the same they all face the problem as I am facing. Instead of covering entire screen while recording please zoom the coding window so that even in small screens we can see the videos without stressing our eyes.

    • @ToskersCorner
      @ToskersCorner  7 ปีที่แล้ว +2

      Hey Ravi, thanks for commenting.
      I became aware of this a while after making my initial videos. Unfortunately older ones such as this do not zoom, though with my newer videos I am making do. If it is any help, the code for this episode is in the description. Perhaps at some point I may also re-upload some of my videos to be mobile friendly. Sorry for this inconvenience.

    • @raviprasad2379
      @raviprasad2379 7 ปีที่แล้ว +1

      Thanks for the reply. You are doing a great job all your videos are easy to understand.

    • @ToskersCorner
      @ToskersCorner  7 ปีที่แล้ว

      Hey, I uploaded a new review video and thought of you. I used a different method to zoom in and out of my code for the video. Let me know if this method is better for you on your smart phone! th-cam.com/video/-DYMwV9tA9c/w-d-xo.html

    • @raviprasad2379
      @raviprasad2379 7 ปีที่แล้ว

      ToskersCorner Hi buddy, I am so happy because you did what you said and replied back. I went through the video compared to previous videos this I feel better but still I fell little zoom is required. What I feel is you can unpin solutions explorer while coding so you can zoom more and we can see better. If you don't mind give me your mail id I will send you the screen shot that I took from my phone Or you can only use your smart phone to see. My phone screen size is 5.

    • @ToskersCorner
      @ToskersCorner  7 ปีที่แล้ว

      You can shoot me emails at toskerscorner@outlook.com !

  • @Ianuarius
    @Ianuarius 3 ปีที่แล้ว

    You really seem to like Message Boxes.

  • @johnsailor3590
    @johnsailor3590 6 ปีที่แล้ว

    C# is really complex

    • @ToskersCorner
      @ToskersCorner  6 ปีที่แล้ว

      Anything is complex if it is new to you! Though these videos are intended for something a bit more advanced, are you very new to C# and programming in general? If so, how long?

    • @johnsailor3590
      @johnsailor3590 6 ปีที่แล้ว +1

      ive been developing since 2015 but as web developer now im trying to get into desktop apps ( just for fun ), i really get it i mean i understand how it works but i dont like the excesive code to do a pretty simple stuff in WPF, i know we have winforms but idk ... i think i need to get into a big project to understand the because of the causes

  • @FollyOx
    @FollyOx 6 ปีที่แล้ว

    IMO Just do videos about the title, i dont want to know about you app just how to use commands.

    • @ToskersCorner
      @ToskersCorner  6 ปีที่แล้ว

      I agree, and I try not to go too far away, but sometimes the context is really important if you want to actually understand it and not just "copy/paste" the implementation. Can you give me an example time stamp in this video where you think I go off topic a little too much? (I see I mentioned this in an older comment, but I forget where in which I was referring)

    • @FollyOx
      @FollyOx 6 ปีที่แล้ว +2

      I re-watched it at x1.25 and its fine, I was too harsh. Thank you for this video it was very useful resource

  • @adalbertbiadatz4138
    @adalbertbiadatz4138 3 ปีที่แล้ว

    Great tutorial!

  • @GAGANDEEP901
    @GAGANDEEP901 8 ปีที่แล้ว +1

    Very helpful, Thanks man!!