Reputation:
I was just googling the difference between WPF Command and Event in WPF. i landed on the following page of stackoverflow where the discussion is going on.
What is the difference between WPF Command and Event?
I am only able to understand following from there
Am I right? Is there any other difference between them?
Upvotes: 8
Views: 5142
Reputation: 7894
You're right but only partly.
MVVM
paradigm. Simply saying events are hardly pluggable, you can't bind to event handler. Nevertheless there is no limit to use commands in presentation layer but there is no benefits of doing so. As well as you could catch your control in BLL and attach event handler to it but this case is even worse.Also commands gives you some free benefits. For example using command element'll be disabled if CanExecute()
returns false. Another benefit is that using commands forces you to fo follow Separation of concerns principle.
Upvotes: 6
Reputation: 3435
An Event is a trigger that occurs when something happens in the UI. A Command is how this event is handled by your domain model.
Upvotes: 5