Commands In WPF

  Рет қаралды 77,189

DotNetSkoool

DotNetSkoool

Күн бұрын

Hi Guys , Let us understand what are commands in WPF. WPF commands play a important role to avoid code behind and build apps using MVVM pattern. Let us implement a very simple command. Video is bit long to make you understand but it is worthy time spent to understand commands.
Find the code here
dotnetskoool.b...

Пікірлер: 72
@rahulgoutham7102
@rahulgoutham7102 9 ай бұрын
I feel that it is the best video to learn that explains the Commands in WPF. Thank you very much, Sir 🙏
@iXmerof
@iXmerof 7 жыл бұрын
sometimes you're speaking too quickly, but I like how well organised is your speech here. Thank you for good explanation
@1ThomasTom
@1ThomasTom 3 жыл бұрын
Crystal clear! Thumbs up for this short clip.
@davesimon9192
@davesimon9192 6 жыл бұрын
Good video. The only thing about mvvm I don't like is sometimes all of the additional classes and code compared to regular code behind can actually makes your code base more convoluted.
@omervts8118
@omervts8118 6 жыл бұрын
Thank you for the video. Your video is very helpful but there is two things that i wanted to point out. 1-) You placed the logic on ViewModel, which shouldnt have any logic inside. 2-) By connecting the View model with logic inside to the xml, you have done nothing but pointing code behind(MainForm.cs) to ViewModel.cs. Thank you again for your time and efford.
@shobhamahadev118
@shobhamahadev118 7 ай бұрын
A best tutorial on KZbin on WPF. Please do add videos on concepts like how to implement icons, item templates, scrolling and adding behaviors etc.
@anulekhachatterjee
@anulekhachatterjee 5 жыл бұрын
Extremely helpful videos. Thank You Sir!
@asifzaffar343
@asifzaffar343 4 жыл бұрын
Helped me alot to understand basic, than you so much.
@signon77
@signon77 5 жыл бұрын
Thanks for uploading this video. I recreated all your steps in Visual Studio 2019 Community Edition successfully.
@gaugmash
@gaugmash 3 жыл бұрын
Very well organised and simple to understand
@maxron6514
@maxron6514 2 жыл бұрын
Outstanding explanation, it can’t get any better than this!
@mokhtarbelhachi4092
@mokhtarbelhachi4092 4 жыл бұрын
Thank you a lot you have the talent of explanation
@lukeaustin3313
@lukeaustin3313 3 жыл бұрын
Great tutorial tbh, the way you explained it made perfect sense. Thanks!
@sergeyt4118
@sergeyt4118 4 жыл бұрын
This is a good example to illustrate my hesitation while I'm learning C# and .NET in general: I can see the author simplified the example to the best level possible, but I still can not comprehend as a generally logically thinking human beeing - why the hell the authors of this computer language made it so that to implement a simple thing one would reasonably hope to have done in a few lines of code and in just a few property settings hwere needed, it requires tens of lines of code, a number of entities and multi-level representation of the logically same thing (with repetition of entities like onion layers) ?? whose sick mind could invent such a programming philosophy I keep wondering? To me its an ideal source of many mistakes and bugs a general piece of SW is notorious with, or when finally bug-fixed and tested ok than explains why it costs so much to develop software (when another programmer struggles to understand what the author meant to do here and there if not properly commented in the code or without documentation). Doesn't the general science rule (citation from Einstein or someone else?) state that the right thing should be short and clear. To me the code should better be longer in terms of lines but more humanly understandable, to hell with these multiple layers of abstraction:)) Or what is this, a conspiracy? - make it difficult to understand for others and profit from your competitive advantage - artificially created logical constructs? :))
@abdoutech6861
@abdoutech6861 4 жыл бұрын
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH thank you, you truly made me laugh from the bottom of my heart XD
@lushlush3927
@lushlush3927 4 жыл бұрын
It's not to make things harder. It's used to decouple UI from the business logic. And though for this easy MessageBox.Show he has so much overhead in this example, the overhead is static here. He will be able to reuse that (Relay)Command class (and possibly ViewModelBase class). It's a lot of overhead for a simple and small WPF application, but it's the opposite when the application comes enormous and you want to couple your logic to a different UI. The MVVM design pattern is honestly not that complicated, though i think the documentation of it by many people seems disorganised. Once you understand that INotifyPropertyChanged is simply an event in the Setter methods of properties that helps UI to know when to re-get the value of that property after it has been set to something else and that commands are really just a public delegate void (object) that you pass a function into and can call from your UI using
@ginanjarbambang7122
@ginanjarbambang7122 5 жыл бұрын
very thanks.. finally i understand view model...
@aslalsujath1341
@aslalsujath1341 6 жыл бұрын
very useful for beginners.Thank you so much.
@spavan1249
@spavan1249 5 жыл бұрын
Very Helpful and theory is really good.
@mamatovakbar6954
@mamatovakbar6954 3 жыл бұрын
Very useful lesson 👍 thank you
@MB-pt8hi
@MB-pt8hi 6 жыл бұрын
I don't understand your example with print command. Why should we write the code with codebehind page three times. I don't think anyone is doing it. You just write once a print function and just call it three times in the events in the code behind page. By using commands you also have to call the command three times, just not in the code behind page but in the binding of the view. Correct me if you have another opinion
@raveendrababu6637
@raveendrababu6637 7 жыл бұрын
thank for giving a wonderful video on command
@dotnetskoool5809
@dotnetskoool5809 7 жыл бұрын
Welcome....
@ritasrivastava6654
@ritasrivastava6654 3 жыл бұрын
Very good tutorial.
@shilpav44
@shilpav44 7 жыл бұрын
Awesome Its very helpfull Thank You....
@gauravagarwal2460
@gauravagarwal2460 7 жыл бұрын
you did not use the eventhandler "canExecuteChanged" anywhere...
@anjaliparikh9220
@anjaliparikh9220 5 жыл бұрын
Thanks for the wonderful video, I understood MVVM concept and I did practical as well, my both class files are as like yours still, I am getting the error that my namespace does not find the class. i tried to solve several ways have not got any luck . would you please suggest any solution to cure this problem !!!
@lushlush3927
@lushlush3927 4 жыл бұрын
You can set the Datacontext of the window from the UI using If you have your viewmodel in a folder then you could create a new xml namespace: xmlns:nameofchoice="clr-namespace:SolutionName.FolderName"
@kimh.6680
@kimh.6680 4 жыл бұрын
I have a generic command that I've been using for years, which looks almost the same as yours. I wonder why Microsoft doesn't deliver this implementation instead of simply providing ICommand without any standard implementation.
@TT-ud5gf
@TT-ud5gf 6 жыл бұрын
It seems that Command is for Button click use case. Should Slider, ComboBox... use Command to eliminate the code behind?
@sanjuprajapati068
@sanjuprajapati068 8 жыл бұрын
pls sharesome idea about RoutedCommand and difference between Relay and RoutedCommand..
@francocrespo6555
@francocrespo6555 3 жыл бұрын
Excelente explicación
@viveksaurabh75
@viveksaurabh75 7 жыл бұрын
HI good one...Can we get the vieo related to difference between ICommand and Routed Events ...and when to implement it..Please make a video for this
@prasantabiswal9074
@prasantabiswal9074 2 жыл бұрын
excellent explaination of complex in easy way. I want to point out why canexecutemethod return true in both command class and viewmodel class.
@alaatellawi1011
@alaatellawi1011 3 жыл бұрын
Thank you very much for your video, I have one question please , till now I can’t understand that, your command has als default Click event , can I build command working with other events? For example hover or any other event? Thank you so much
@chandranshugautam8070
@chandranshugautam8070 2 жыл бұрын
My question is how is it knowing that it has to execute that command on Click only. Why not on hover or anything else. We have not mentioned click anywhere??? Please help.
@chandranshugautam8070
@chandranshugautam8070 2 жыл бұрын
Any lead??
@anveshbabuunnam1658
@anveshbabuunnam1658 5 жыл бұрын
Thank you for explanation, Can you please make video how to hide fields on click of button/Radio button during runtime in MVVM
@abhaykumarsharma5672
@abhaykumarsharma5672 Жыл бұрын
Hii Sir, Your videos are great to learn.. But i have one doubt is that, how to copy observable collection to clipboard in WPF Please help
@pcanteroh
@pcanteroh 3 жыл бұрын
Hello, excellent video; Can you upload similar video in "Visual Basic" language applied in 2 or more windows?
@quantomic1106
@quantomic1106 5 жыл бұрын
I have a "ViewModel" does not exist in the namespace "clr-namespace" error.
@euphoric3464
@euphoric3464 2 жыл бұрын
Hey i got the same error!!
@PabloHelal
@PabloHelal 4 жыл бұрын
Gracias.
@abhijitv
@abhijitv 7 жыл бұрын
AWESOME!!!!
@n.renukachowdary6057
@n.renukachowdary6057 5 жыл бұрын
Please provide more examples wpf with mvvm
@strigocoruja
@strigocoruja 6 жыл бұрын
Thanks!
@sashtana5419
@sashtana5419 5 жыл бұрын
Hi, I am new to WPF. Can somebody explain me how actually this code works. Not able to understand how executeMethod of ViewModel is executed.
@oussamasethoum2755
@oussamasethoum2755 3 жыл бұрын
I faced an error when trying to use it's saying: The name ViewModel does not exist in the clr-namespace:Sample
@oussamasethoum2755
@oussamasethoum2755 3 жыл бұрын
I cleaned the solution and rebuild it, it got fixed ^^.
@sanwalchaudhry2099
@sanwalchaudhry2099 5 жыл бұрын
we have not implemented EventHandler CanExecuteChanged... Why?
@Susandwyer
@Susandwyer Ай бұрын
I just don't get commands, especially the claim that there is no code behind, and then proceed to write 2 full classes of code behind. So event = Add message box. And command = walk a mile and then add message box.
@motivationguru7155
@motivationguru7155 10 ай бұрын
Why we have not use data soure
@arulkumarmca
@arulkumarmca 5 жыл бұрын
public ClickViewModel() { MyCommand = new OnclickCommand(ExecuteMethod, canExecuteMethod); } This, above parameter value pass error , how to resolve problem
@anushakommu1538
@anushakommu1538 6 жыл бұрын
When writing code in Codebehind page is very simple then why to use these many lines of coding just to call single click event?
@duncanmcdonald5250
@duncanmcdonald5250 6 жыл бұрын
You are right in this simple case it's easier and quicker to write it into the CodeBehind of the View. But we are working towards understanding and using the MVVM pattern which is fundamentally the separation of the Business Logic code and the UI code. Perhaps you should re-watch the "MVVM Pattern in WPF" video again for the explanation of why we want to do this.
@dharmaraosalana7977
@dharmaraosalana7977 4 жыл бұрын
Can you please share the codes as well for the benfit of time
@dotnetskoool5809
@dotnetskoool5809 4 жыл бұрын
Yes will share the same..
@dharmaraosalana7977
@dharmaraosalana7977 4 жыл бұрын
@@dotnetskoool5809 great thx a lot . Tutorials are really awesome and simple
@dharmaraosalana7977
@dharmaraosalana7977 4 жыл бұрын
where can i get the code. Did you get time to upload the code?
@dotnetskoool5809
@dotnetskoool5809 4 жыл бұрын
Please check the video discription. Thanks
@dharmaraosalana7977
@dharmaraosalana7977 4 жыл бұрын
@@dotnetskoool5809 : you nailed it thx for sharing.It saved lot of time
@hithucheriyan8845
@hithucheriyan8845 6 жыл бұрын
Error occures
@himanshumishra853
@himanshumishra853 6 жыл бұрын
looks like class name you use view model instead of ViewModel
@mehmetturan8500
@mehmetturan8500 5 жыл бұрын
Thank you for helpful video.? for asking question to you ,can you share your email?
WPF MVVM Implementation
28:41
DotNetSkoool
Рет қаралды 92 М.
Attached Properties in WPF
18:19
DotNetSkoool
Рет қаралды 28 М.
My daughter is creative when it comes to eating food #funny #comedy #cute #baby#smart girl
00:17
哈莉奎因怎么变骷髅了#小丑 #shorts
00:19
好人小丑
Рет қаралды 47 МЛН
Как мы играем в игры 😂
00:20
МЯТНАЯ ФАНТА
Рет қаралды 1,3 МЛН
Value Converters in WPF
14:50
DotNetSkoool
Рет қаралды 28 М.
WPF Resources
15:10
DotNetSkoool
Рет қаралды 77 М.
WPF Commands Explained  [1 of 2 ]
28:14
Tactic Devs
Рет қаралды 8 М.
Understanding INotifyPropertyChanged Interface in WPF
12:40
DotNetSkoool
Рет қаралды 74 М.
Dependency Properties in WPF
19:24
DotNetSkoool
Рет қаралды 114 М.
Routed Events in WPF
15:29
DotNetSkoool
Рет қаралды 47 М.
Types of Triggers in WPF
14:13
DotNetSkoool
Рет қаралды 54 М.
The Basics of Data Binding in WPF
20:53
Tactic Devs
Рет қаралды 42 М.
IDataErrorInfo Interface in WPF
13:09
DotNetSkoool
Рет қаралды 23 М.
Layouts In WPF
24:15
DotNetSkoool
Рет қаралды 54 М.
My daughter is creative when it comes to eating food #funny #comedy #cute #baby#smart girl
00:17