Тёмный

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

ToskersCorner
Подписаться 7 тыс.
Просмотров 50 тыс.
50% 1

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.opinionstag...
Get the code from this episode
toskerscorner.c...
*Support me on Patreon
/ toskerscorner
** Tip Jar **
Paypal: toskerscorner@outlook.com
BTC: 3DkvwvcQ8Vt2U84jdtEhNBx2Ueai3Xttmu
ETH: 0xFf79A145e1ED6F538607Ec374968e605cbea758b
BCH: qqpgrnzuhc5hav4e79m8nfhmugs46jtl0ujxcu0tj5
LTC: MHXQmJA3hkwTPeArB9QPNkcLiHQx723yMb

Опубликовано:

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 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.
@vxco
@vxco 5 лет назад
Very good example of using ICommand in the MVVM pattern. Thanks a lot for sharing
@metin4yt
@metin4yt 4 года назад
Omg, this was so so so simple but the documentation makes it seem so intimidating. Thanks for the video.
@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. 👍👍
@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!
@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!
@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.
@omervts8118
@omervts8118 6 лет назад
that was a great lesson. Easy to follow and simple enough. Thank you sir.
@sandrinaribeiro7978
@sandrinaribeiro7978 3 года назад
Thank you, your explanation is really clear.
@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
@saturninramirez1107
@saturninramirez1107 2 года назад
thanks , very good "PROFESSOR" !
@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.
@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.
@lesterfonseca7863
@lesterfonseca7863 4 года назад
thanks man! good job
@TaughtSimply
@TaughtSimply 6 лет назад
This was amazing, super helpful and easy to follow! Thanks!
@imaginative-monkey
@imaginative-monkey 5 лет назад
I wish the source code was available on github, the link doesn't work. Great video, thank you! :-)
@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.
@laszloebner8700
@laszloebner8700 5 лет назад
Thank for the video, great work, clear explanation.
@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.
@MrMaczupiczu
@MrMaczupiczu 7 лет назад
So underrated video.
@ToskersCorner
@ToskersCorner 7 лет назад
MrMaczupiczu Thank you!
@papercut197
@papercut197 5 лет назад
Wonderful Video. Thank you for posting it!
@devall4324
@devall4324 6 лет назад
Merci beaucoup pour cette video
@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.
@smarttransport7100
@smarttransport7100 4 года назад
You're the best Bro
@GuildOfCalamity
@GuildOfCalamity 3 года назад
Great video. Would like to see you do some on UWP.
@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!
@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
@Hazit90
@Hazit90 4 года назад
Just what I needed. Thanks :)
@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!
@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?
@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?
@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.
@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?
@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?
@lazermajor7908
@lazermajor7908 4 года назад
how and where does public void Execute(object parameter) get called?
@MisterThug187
@MisterThug187 5 лет назад
Great Job my Friend
@vincentbarrilliot9777
@vincentbarrilliot9777 6 лет назад
was quite useful, 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.
@matheuscastrosilva1632
@matheuscastrosilva1632 5 лет назад
Hi, How can I fire the CanExecuteChanged event from my ViewModel?
@E7YSIAN
@E7YSIAN 6 лет назад
Absolute legend!
@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.
@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
@icstrimterror
@icstrimterror 7 лет назад
Thanks for the video(s)!
@ToskersCorner
@ToskersCorner 7 лет назад
Thanks for watching them. :)
@siri7043
@siri7043 4 года назад
hi please upload a video to export datagrid to excel file in wpf mvvm
@sleepysundaymorning5034
@sleepysundaymorning5034 6 лет назад
The action implementation can be both done through method of View Model, or through the command itself.
@ToskersCorner
@ToskersCorner 6 лет назад
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
@User_Masuri
@User_Masuri 5 лет назад
This is so great!!!!!! :)
@_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
@MultiMChelper
@MultiMChelper 6 лет назад
Thank you so much!
@AkshayKumarTK
@AkshayKumarTK 4 года назад
The code download link is dead
@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.
@ToskersCorner
@ToskersCorner 2 года назад
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?
@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 😫
@KitPatron
@KitPatron 7 лет назад
Best video about ICommand in WPF I ever saw! Thanks, very informative!
@jonpopeadventures
@jonpopeadventures 3 года назад
Excellent video, well explained, thank you for creating!
@akashverma1640
@akashverma1640 4 года назад
Loved It ,literally It's the same as needed.
@EK-ck2xf
@EK-ck2xf 6 лет назад
Really useful. Many thanks
@amadlover
@amadlover 5 лет назад
buckling springs ?
@cyukore1796
@cyukore1796 7 лет назад
Nice tutorial
@ToskersCorner
@ToskersCorner 7 лет назад
Thanks!
Далее
C# WPF - Relay/Delegate Commands [Part 2]
21:25
Просмотров 33 тыс.
C# WPF Tutorial - Using INotifyPropertyChanged
22:01
Просмотров 49 тыс.
We finally APPROVED @ZachChoi
00:31
Просмотров 2,2 млн
WPF Controls with MVVM: ItemsControl
33:34
Просмотров 83 тыс.
OpenAI’s New ChatGPT: 7 Incredible Capabilities!
6:27
Object-Oriented Programming is Bad
44:35
Просмотров 2,3 млн
What is the Smallest Possible .EXE?
17:04
Просмотров 396 тыс.
Nix explained from the ground up
23:39
Просмотров 31 тыс.
WPF C# Professional Modern Flat UI Tutorial
36:44
Просмотров 820 тыс.
We finally APPROVED @ZachChoi
00:31
Просмотров 2,2 млн