Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What comes first - Command or EventHandler?

In context of Microsoft's MVVM pattern and its Commanding/Event Handling aspects consider I am doing both binding a Command to a Control (say a Button) and subscribing to the control's Click event.

Is there any general rule what action takes place first - the processing of the code associated with the command or the one associated with the corresponding event handler?

like image 496
marc wellman Avatar asked Jul 12 '12 14:07

marc wellman


People also ask

What is C# Eventhandler?

An event handler, in C#, is a method that contains the code that gets executed in response to a specific event that occurs in an application. Event handlers are used in graphical user interface (GUI) applications to handle events such as button clicks and menu selections, raised by controls in the user interface.

Why should we use routed commands instead of events?

Routed commands give you three main things on top of normal event handling: Routed command source elements (invokers) can be decoupled from command targets (handlers)—they do not need direct references to one another, as they would if they were linked by an event handler.

What is an event handler method?

Event handlers In the event handler, you perform the actions that are required when the event is raised, such as collecting user input after the user clicks a button. To receive notifications when the event occurs, your event handler method must subscribe to the event.

What are events How are events and delegates associated in the .NET framework?

NET Framework is based on having an event delegate that connects an event with its handler. To raise an event, two elements are needed: A delegate that identifies the method that provides the response to the event. Optionally, a class that holds the event data, if the event provides data.


1 Answers

EventHandlers are triggered before the bound ICommand.

like image 102
Jone Polvora Avatar answered Oct 13 '22 04:10

Jone Polvora