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

  Рет қаралды 50,159

ToskersCorner

ToskersCorner

Күн бұрын

In this video, as well as the following ones, we will be covering using commands in WPF. This particular episode will cover learning what the ICommand interface is and well as over-viewing our options for implementations.
The coding portion of this video covers implementing commands with singular class handlers with and without parameters. The following episodes will cover implementing Relay/Delegate commands.
Survey mentioned in the video
www.opinionstage.com/tosker/im...
Get the code from this episode
toskerscorner.com/c-wpf-comman...
*Support me on Patreon
/ toskerscorner
** Tip Jar **
Paypal: toskerscorner@outlook.com
BTC: 3DkvwvcQ8Vt2U84jdtEhNBx2Ueai3Xttmu
ETH: 0xFf79A145e1ED6F538607Ec374968e605cbea758b
BCH: qqpgrnzuhc5hav4e79m8nfhmugs46jtl0ujxcu0tj5
LTC: MHXQmJA3hkwTPeArB9QPNkcLiHQx723yMb

Пікірлер: 93
@generalcontrol
@generalcontrol 7 жыл бұрын
WPF is indeed mind twisting. Thanks for making learning it a bit less painful.
@ToskersCorner
@ToskersCorner 7 жыл бұрын
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 жыл бұрын
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.
@KitPatron
@KitPatron 6 жыл бұрын
Best video about ICommand in WPF I ever saw! Thanks, very informative!
@vxco
@vxco 5 жыл бұрын
Very good example of using ICommand in the MVVM pattern. Thanks a lot for sharing
@metin4yt
@metin4yt 3 жыл бұрын
Omg, this was so so so simple but the documentation makes it seem so intimidating. Thanks for the video.
@dw71273
@dw71273 3 жыл бұрын
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!
@omervts8118
@omervts8118 6 жыл бұрын
that was a great lesson. Easy to follow and simple enough. Thank you sir.
@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.
@TaughtSimply
@TaughtSimply 6 жыл бұрын
This was amazing, super helpful and easy to follow! Thanks!
@jonpopeadventures
@jonpopeadventures 3 жыл бұрын
Excellent video, well explained, thank you for creating!
@papercut197
@papercut197 5 жыл бұрын
Wonderful Video. Thank you for posting it!
@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
@laszloebner8700
@laszloebner8700 5 жыл бұрын
Thank for the video, great work, clear explanation.
@akashverma1640
@akashverma1640 4 жыл бұрын
Loved It ,literally It's the same as needed.
@crusaderzero3984
@crusaderzero3984 6 жыл бұрын
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 6 жыл бұрын
Nelson Yang Thank you very much for your comment. Its always good to hear about my videos helping people!
@totototo4093
@totototo4093 3 жыл бұрын
And boom. I now understand Command and Bindings. Thank you so much.
@MagoMakes
@MagoMakes Жыл бұрын
Damn - I think I've found my go-to guy for transitioning me into WPF MVVM! Excellent tutorial - thanks. 👍👍
@sandrinaribeiro7978
@sandrinaribeiro7978 3 жыл бұрын
Thank you, your explanation is really clear.
@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 жыл бұрын
Glad I could help. Feel free to check out some other videos if you wish!
@Hazit90
@Hazit90 4 жыл бұрын
Just what I needed. Thanks :)
@lesterfonseca7863
@lesterfonseca7863 3 жыл бұрын
thanks man! good job
@EK-ck2xf
@EK-ck2xf 6 жыл бұрын
Really useful. Many thanks
@vincentbarrilliot9777
@vincentbarrilliot9777 5 жыл бұрын
was quite useful, thanks!
@E7YSIAN
@E7YSIAN 6 жыл бұрын
Absolute legend!
@saturninramirez1107
@saturninramirez1107 2 жыл бұрын
thanks , very good "PROFESSOR" !
@MisterThug187
@MisterThug187 5 жыл бұрын
Great Job my Friend
@User_Masuri
@User_Masuri 5 жыл бұрын
This is so great!!!!!! :)
@smarttransport7100
@smarttransport7100 4 жыл бұрын
You're the best Bro
@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 жыл бұрын
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.
@icstrimterror
@icstrimterror 7 жыл бұрын
Thanks for the video(s)!
@ToskersCorner
@ToskersCorner 7 жыл бұрын
Thanks for watching them. :)
@devall4324
@devall4324 6 жыл бұрын
Merci beaucoup pour cette video
@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!
@MultiMChelper
@MultiMChelper 6 жыл бұрын
Thank you so much!
@ElCidPhysics90
@ElCidPhysics90 Жыл бұрын
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 Жыл бұрын
I say redo but really mean update with current WPF methodology
@GuildOfCalamity
@GuildOfCalamity 3 жыл бұрын
Great video. Would like to see you do some on UWP.
@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.
@cyukore1796
@cyukore1796 7 жыл бұрын
Nice tutorial
@ToskersCorner
@ToskersCorner 7 жыл бұрын
Thanks!
@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.
@MB-pt8hi
@MB-pt8hi 6 жыл бұрын
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?
@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
@MrMaczupiczu
@MrMaczupiczu 7 жыл бұрын
So underrated video.
@ToskersCorner
@ToskersCorner 6 жыл бұрын
MrMaczupiczu Thank you!
@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?
@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?
@imaginative-monkey
@imaginative-monkey 5 жыл бұрын
I wish the source code was available on github, the link doesn't work. Great video, thank you! :-)
@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?
@matheuscastrosilva1632
@matheuscastrosilva1632 4 жыл бұрын
Hi, How can I fire the CanExecuteChanged event from my ViewModel?
@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.
@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.
@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.
@lazermajor7908
@lazermajor7908 4 жыл бұрын
how and where does public void Execute(object parameter) get called?
@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 6 жыл бұрын
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.
@_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 жыл бұрын
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
@ABsazerNer
@ABsazerNer 4 жыл бұрын
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 😫
@AkshayKumarTK
@AkshayKumarTK 4 жыл бұрын
The code download link is dead
@amadlover
@amadlover 5 жыл бұрын
buckling springs ?
@siri7043
@siri7043 4 жыл бұрын
hi please upload a video to export datagrid to excel file in wpf mvvm
@sleepysundaymorning5034
@sleepysundaymorning5034 5 жыл бұрын
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 5 жыл бұрын
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.
@sleepysundaymorning5034
@sleepysundaymorning5034 5 жыл бұрын
The action implementation can be both done through method of View Model, or through the command itself.
@ToskersCorner
@ToskersCorner 5 жыл бұрын
You are correct. And that is shown in part 2! -- i believe, it has been a while.
@sleepysundaymorning5034
@sleepysundaymorning5034 5 жыл бұрын
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 5 жыл бұрын
@@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 5 жыл бұрын
@@ToskersCorner ill just text you my problem, and as you want you may answer it
@sleepysundaymorning5034
@sleepysundaymorning5034 5 жыл бұрын
@@ToskersCorner youtu.be/addme/MIQcMcwgaA4aKIVSY4uLeHXLQf7Row invitation link to chat
@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
@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 Жыл бұрын
Couldn't watch more that 20 seconds after you opened visual studio. Your keyboard is beyond annoying.
@ToskersCorner
@ToskersCorner Жыл бұрын
Sorry you feel that way. :)
@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.
@Optimuseq
@Optimuseq 2 жыл бұрын
How to send multiple parameters?
C# WPF - Relay/Delegate Commands [Part 2]
21:25
ToskersCorner
Рет қаралды 33 М.
C# WPF Tutorial - Using INotifyPropertyChanged
22:01
ToskersCorner
Рет қаралды 48 М.
Mama vs Son vs Daddy 😭🤣
00:13
DADDYSON SHOW
Рет қаралды 50 МЛН
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 12 МЛН
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
Deep Dive on LINQ with Stephen Toub
1:23:59
dotnet
Рет қаралды 57 М.
Is LEARNING WPF still WORTH it in 2023?
10:59
tutorialsEU
Рет қаралды 44 М.
Making async code run faster in C#
10:28
Nick Chapsas
Рет қаралды 105 М.
Commands In WPF
20:34
DotNetSkoool
Рет қаралды 76 М.
Why Isn't Functional Programming the Norm? - Richard Feldman
46:09
C# WPF Tutorial - Multiple Views
20:00
ToskersCorner
Рет қаралды 166 М.