M
M
Maronus2014-09-25 22:00:56
C++ / C#
Maronus, 2014-09-25 22:00:56

What is the essential difference between Button.Click and Button.Command and which is better to use?

Actually the question is in the title.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AlexP11223, 2014-09-25
@Maronus

Well, in WPF, the use of the MVVM pattern is popular, so they often use Binding to data and commands (from the ViewModel) instead of code behind in the View itself (Window.xaml.cs).
And the command, for example, is convenient that there is CanExecute, where you can easily set the conditions for enabling the button.

A
Alexcei88, 2014-12-06
@Alexcei88

Imagine that you have two buttons that should call the same function, and if one button is pressed, then both buttons should be blocked, and it becomes available again only when the action is completed.
1) If you do this using click, then you yourself need to prescribe the blocking of buttons after clicking on one of them, and at the end of the action, unblock them yourself.
2) If this is done using command, then the buttons will be automatically blocked and unblocked depending on whether this command is currently being executed (using the CanExecute command event)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question