C# WPF - Commands [Part 1 Intro + Singular Commands]

Поділитися
Вставка
  • Опубліковано 17 жов 2024

КОМЕНТАРІ • 93

  • @generalcontrol
    @generalcontrol 7 років тому +27

    WPF is indeed mind twisting. Thanks for making learning it a bit less painful.

    • @ToskersCorner
      @ToskersCorner  7 років тому +3

      Yes, it can be painful -- but I have learned this is with everything(As I'm sure you know)! I'm glad that I could aid in the confusion this can sometimes bring. When taking small bites at a time, confusing things can become very clear.

    • @VaderFaderVader
      @VaderFaderVader 7 років тому +5

      I'm glad to hear i'm not alone in feeling challenged by learning WPF.
      I find that is's surprisingly difficult to fathom ...

  • @TheJoker-te7te
    @TheJoker-te7te 2 роки тому

    * 5 years later... * : survey taken! Thank you for these tutorials, they are all well made and very helpful.

  • @dw71273
    @dw71273 3 роки тому +4

    Suggstion: Make sure your volume is consistent across all your videos. The first one in this series are louder than the following ones. Excellent series! Very helpful to a WPF noob!

  • @vxco
    @vxco 5 років тому +1

    Very good example of using ICommand in the MVVM pattern. Thanks a lot for sharing

  • @totototo4093
    @totototo4093 3 роки тому

    And boom. I now understand Command and Bindings. Thank you so much.

  • @MagoMakes
    @MagoMakes 2 роки тому

    Damn - I think I've found my go-to guy for transitioning me into WPF MVVM! Excellent tutorial - thanks. 👍👍

  • @Diegoad1
    @Diegoad1 Рік тому

    Hey Toskers thanks for your video! I have a question : Can I have 2 classes "MessageCommand"? One to use with Commands with parameters and another with without parameters? What do you think about this? Thanks

  • @metin4yt
    @metin4yt 4 роки тому

    Omg, this was so so so simple but the documentation makes it seem so intimidating. Thanks for the video.

  • @Exclusivelolviews
    @Exclusivelolviews 5 років тому

    How would i use this when listening for KeyDown events? Right now i have it set up such that the KeyDown events triggers a method, written in the 'window' xaml tag. Seems like i am not able to use bindings with KeyDown events. any tips?

  • @JustinUrban1
    @JustinUrban1 6 років тому

    Thank you for making this simple. I am just jumping into MVVM and appreciate the example that does not over complicate the process. I have been taught code-behind all throughout college, but we never delved into any of this wonderful stuff. Goodbye code-behind. At least for apps. I was going for Software Engineering so that is a big difference, but they also taught the app dev side.

    • @ToskersCorner
      @ToskersCorner  6 років тому +1

      Glad I could help. Feel free to check out some other videos if you wish!

  • @jaderdaconceicao3695
    @jaderdaconceicao3695 5 років тому

    really It's very easy, considering your way to use teaching us. Thanks for help. I'm learning to develop since zero with your teaching

  • @crusaderzero3984
    @crusaderzero3984 7 років тому

    Thank you so much for this tutorial! This is only one that explicitly explain how those delegation work, also I love the metaphorical ways (Universal remote for various appliances) you used to explain why we use this technique in the first place. That make me much much effort to understand the concept compare to those obscure Microsoft Documents and complicated examples in CodeProject website.

    • @ToskersCorner
      @ToskersCorner  7 років тому

      Nelson Yang Thank you very much for your comment. Its always good to hear about my videos helping people!

  • @KitPatron
    @KitPatron 7 років тому

    Best video about ICommand in WPF I ever saw! Thanks, very informative!

  • @abinashbaral3266
    @abinashbaral3266 5 років тому

    Error Under Constructor: "There is no argument given that corresponds to the required formal parameter 'execute' of 'ObservableObject.ObservableObject(Action)'".
    Error Under parameter of ObservableObject: cannot convert method group to Action
    I don't understand whats the problem. Can you please suggest any suggestion.

  • @MrBa143
    @MrBa143 5 років тому

    How would i go about changing a View.Frame.Content using bindings? I assume that it is the ViewModel that needs to change it based on "x" and "y", and not the view itself, where the frame lies?

  • @MB-pt8hi
    @MB-pt8hi 7 років тому

    Thanks for the video. I have a problem with the source. For me the textbox context is not showing in the messagebox. Somehow the set method of the property is not raised.
    I tried to get your source code but clicking on the link just redirects me on the home page of toskercorner and not to the source. How can I get the source?

  • @ElCidPhysics90
    @ElCidPhysics90 2 роки тому

    Man I wish you would redo your WPF videos. You have the best explanations of why certain things are done. Very solid videos.

    • @ElCidPhysics90
      @ElCidPhysics90 2 роки тому

      I say redo but really mean update with current WPF methodology

  • @miloszodin
    @miloszodin 7 років тому

    Bada bing, bada boom, thank You :) After this everything seems really clear. The length is spot on and You keep it consistent.

    • @ToskersCorner
      @ToskersCorner  7 років тому

      Glad to hear, which questions have been answered based on your last comment? Some, or all?

    • @miloszodin
      @miloszodin 7 років тому

      Action was the biggest hit for me here. As a bonus I've got some inside on delegates and what is the benefit (beyond of what I've read). I have a github where I'm putting the code so resolved matters and code upgrades are visible even better.

  • @ginanjarbambang7122
    @ginanjarbambang7122 5 років тому

    thanks, but how if textbox empty messegebox warning, or we add checkbox if checked messegebox show if uncheck messegebox not show?
    Can u create sample?

  • @alcidesneto6415
    @alcidesneto6415 Рік тому

    Great tutorial. I'm studying WPF for about 2 weeks. However, after 6:35, it started to need clarification for me. Please make a 5 years video duration to explain these details for a noob like me.

  • @jonpopeadventures
    @jonpopeadventures 3 роки тому

    Excellent video, well explained, thank you for creating!

  • @KacieJscott
    @KacieJscott 4 роки тому

    The volume of your video plays back low compared to the advertisements and other videos in general. You sound great, Clarity is awesome and you articulate the subject matter well. I wonder if your content may be underrated because people are assuming the sound is bad or becoming frustrated after adjusting volume (3x normal my setup none headphones) and getting blasted by the commercials. Keep up the good work.

    • @ToskersCorner
      @ToskersCorner  4 роки тому

      Yeah an unfortunate reality. Funny thing is I was aware of this and would crank my audio up 3x in post production and would still have this issue. Must have been a variety of factors of configuration when recording. Hate to say it, but I am clueless when it comes to that stuff.

  • @sandrinaribeiro7978
    @sandrinaribeiro7978 3 роки тому

    Thank you, your explanation is really clear.

  • @omervts8118
    @omervts8118 6 років тому

    that was a great lesson. Easy to follow and simple enough. Thank you sir.

  • @jaydigging2009
    @jaydigging2009 7 років тому

    Great Video, best I've seen so far on the subject, I'm still confused with delegates but I guess with time and practice I'll get it.

    • @ToskersCorner
      @ToskersCorner  7 років тому +2

      Delegates were certainly confusing for me at first. The best way I can explain them is that you should think of them like variables, but for methods/functions. No different than you assign a number to an int variable, you assign a method to a delegate. You can then invoke it by the container instead of calling the method directly.

    • @jaydigging2009
      @jaydigging2009 7 років тому

      Thanks, after practicing a bit I got it now, you're right it's like a variable for methods.

  • @Jwhite1979
    @Jwhite1979 3 роки тому

    Great video, and I really appreciate your work. But I still don't understand instantiating the viewmodel in the codebehind rather than just setting it in the XAML.

  • @shaihulud4515
    @shaihulud4515 4 роки тому

    Great video - I already watched a few vids from you, and each helped me a bit. Subbed today. Just one thing, I'd like to mention: I always have to raise the volume for your videos a lot. The when the commercials kick in, it's blasting my ears off. So, please, please, raise the volume when editing your vids. Otherwise: thumbs up!!!

    • @ToskersCorner
      @ToskersCorner  4 роки тому

      Yeah my videos vary in that regard. I used to be editing my videos with a really weird speaker, that would mislead me on volume levels when I would render them. Some videos should be better, so sorry! And tell your ears I said sorry too.

  • @_emed84
    @_emed84 7 років тому

    could you tell my how it is happens , that when you call a MessageCommand it will invoke the public void Execute(object parameter) method. How it is happen, that it goes to Execute method directly ? I can't get it.

    • @ToskersCorner
      @ToskersCorner  7 років тому +2

      It can be confusing because some things happen behind the scenes that you did not personally develop. I'll explain the best I can. To put it simply, in your WPF control the `Command` property we bind to is designed to work with the ICommand interface we implement. This is why we must use that interface, because the Command property will look for the `Execute` method in whatever it is bound to -- given it implements the ICommand interface. So yes, when we bind to the `Command` property in our XAML, it knows it must go directly to the execute method. If you still find it confusing, you may understand it more if you look a little more into interfaces and how they work.
      Hope I helped!

    • @_emed84
      @_emed84 7 років тому

      ToskersCorner
      i know-how the interface works. its Haven declarations of method and classes which you have to declare in Chili children class. but it no execute any methods by default like here the execute method. so i have to take it as it have to be, that Command option in xaml will always Look for the Execute method in binded object? please tell me if i get it right?
      many thanks for help!

    • @ToskersCorner
      @ToskersCorner  7 років тому

      The control with the Command property is what knows how to handle it. For example, the `Button` has a built in functionality to know how to use the ICommand interface when its Command property is bound -- It does this with something called an ICommandSource. For further research, you can check out this link: docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/how-to-implement-icommandsource

  • @imaginative-monkey
    @imaginative-monkey 5 років тому +4

    I wish the source code was available on github, the link doesn't work.
    Great video, thank you! :-)

  • @akashverma1640
    @akashverma1640 4 роки тому

    Loved It ,literally It's the same as needed.

  • @TaughtSimply
    @TaughtSimply 6 років тому

    This was amazing, super helpful and easy to follow! Thanks!

  • @matheuscastrosilva1632
    @matheuscastrosilva1632 5 років тому

    Hi, How can I fire the CanExecuteChanged event from my ViewModel?

  • @wasdw246
    @wasdw246 7 років тому

    I realize I'm in way over my depth. Thanks for making the video by the way :)

    • @ToskersCorner
      @ToskersCorner  7 років тому

      It's easy to feel that way. It's a bit of a learning curve, but you will pass it with time and repetition.
      No problem though, feel free to message me if you ever have questions. Always willing to try to help!

  • @lazermajor7908
    @lazermajor7908 4 роки тому

    how and where does public void Execute(object parameter) get called?

  • @GuildOfCalamity
    @GuildOfCalamity 3 роки тому

    Great video. Would like to see you do some on UWP.

  • @saturninramirez1107
    @saturninramirez1107 2 роки тому

    thanks , very good "PROFESSOR" !

  • @laszloebner8700
    @laszloebner8700 5 років тому

    Thank for the video, great work, clear explanation.

  • @MrMaczupiczu
    @MrMaczupiczu 7 років тому +7

    So underrated video.

  • @papercut197
    @papercut197 5 років тому

    Wonderful Video. Thank you for posting it!

  • @smarttransport7100
    @smarttransport7100 4 роки тому

    You're the best Bro

  • @ABsazerNer
    @ABsazerNer 4 роки тому +3

    I watched dozens of videos in mvvm but every time I watch a new one I see myself so beginner, why Microsoft did it hard like that 😫

  • @lesterfonseca7863
    @lesterfonseca7863 4 роки тому +1

    thanks man! good job

  • @Hazit90
    @Hazit90 4 роки тому

    Just what I needed. Thanks :)

  • @abijo5052
    @abijo5052 7 років тому

    Can you do a video on how MMVM fits together? I get all of these interfaces now (due to your great vids) but I can't get how to fit it all in to a full MVVM app

    • @ToskersCorner
      @ToskersCorner  7 років тому

      Daniel Wilkes Sorry for the late response. If you are interested in a video that combines the concepts you could check out my vending machine and notepad series. I do hope to do more videos, but i dont have much time now that school is started up again.

  • @sleepysundaymorning5034
    @sleepysundaymorning5034 6 років тому

    And also, the command implementation you showed in the video can be used for any situation since it doesn't contain any logic, except it doesn't have a proper canexecute method implementation. Good job tho

    • @ToskersCorner
      @ToskersCorner  6 років тому

      I think you may br disregarding the fact that these are educational videos and you are analyzing too deep. They are intended to be baby steps for beginners to grasp the concept before getting in the more nitty gritty. I make implementations as minimal as i can so there is less information to overwhelm beginners, preventing them from focusing on the important points the video is intended to convey.

  • @MisterThug187
    @MisterThug187 5 років тому

    Great Job my Friend

  • @AkshayKumarTK
    @AkshayKumarTK 5 років тому

    The code download link is dead

  • @mohammedsamir5142
    @mohammedsamir5142 5 років тому

    Why do we need Icommand? we can just make its work easily by this code
    {
    Message.Show(messageTextBox.Text);
    } in the button click event.
    😐

    • @youtube.com-handle
      @youtube.com-handle 5 років тому

      yeah but when you have a hefty task, you will need to wrap inside a command instead of a code-behind

  • @EK-ck2xf
    @EK-ck2xf 6 років тому

    Really useful. Many thanks

  • @siri7043
    @siri7043 4 роки тому

    hi please upload a video to export datagrid to excel file in wpf mvvm

  • @devall4324
    @devall4324 6 років тому +1

    Merci beaucoup pour cette video

  • @vincentbarrilliot9777
    @vincentbarrilliot9777 6 років тому

    was quite useful, thanks!

  • @sleepysundaymorning5034
    @sleepysundaymorning5034 6 років тому

    The action implementation can be both done through method of View Model, or through the command itself.

    • @ToskersCorner
      @ToskersCorner  6 років тому +1

      You are correct. And that is shown in part 2! -- i believe, it has been a while.

    • @sleepysundaymorning5034
      @sleepysundaymorning5034 6 років тому

      Yes, i ve just seen it. Working on my final course work on WPF so everything has to be perfect. Can you help me a little bit in chat?

    • @ToskersCorner
      @ToskersCorner  6 років тому

      @@sleepysundaymorning5034 Currently i am a little tied up. I wouldnt be available until abou 3 to 4 hours, and even then maybe not until tomorrow. So its possible, just not sure at the moment.

    • @sleepysundaymorning5034
      @sleepysundaymorning5034 6 років тому

      @@ToskersCorner ill just text you my problem, and as you want you may answer it

    • @sleepysundaymorning5034
      @sleepysundaymorning5034 6 років тому

      @@ToskersCorner youtu.be/addme/MIQcMcwgaA4aKIVSY4uLeHXLQf7Row invitation link to chat

  • @E7YSIAN
    @E7YSIAN 6 років тому +1

    Absolute legend!

  • @amadlover
    @amadlover 5 років тому

    buckling springs ?

  • @User_Masuri
    @User_Masuri 5 років тому

    This is so great!!!!!! :)

  • @icstrimterror
    @icstrimterror 7 років тому

    Thanks for the video(s)!

  • @MultiMChelper
    @MultiMChelper 6 років тому

    Thank you so much!

  • @cyukore1796
    @cyukore1796 7 років тому

    Nice tutorial

  • @juanclopgar97
    @juanclopgar97 4 роки тому

    just watching this first video my mind is like, Why I've to use a command and all that stuff, if I can just use click event! hahahahaha, (Windows forms mind)

  • @stevehoff
    @stevehoff 2 роки тому

    Couldn't watch more that 20 seconds after you opened visual studio. Your keyboard is beyond annoying.

  • @sza1940
    @sza1940 4 роки тому

    At 11:43 like you do not have 20 seconds for an "in a nutshell" explanation... Low effort video

    • @ToskersCorner
      @ToskersCorner  4 роки тому

      I don't like to re-explain things that have been explained in other videos, and you are among the minority because many people appreciate that. Personally, I hate videos that explain things outside the context of the video. It may be 20 seconds, but if just do 20 second explanations for every single thing, they add up.