codingbiz
codingbiz

Reputation: 26386

Event Handling now confusing by listener

I thought I had a good understanding of event handling until now that am reading this Routed Events Overview where Event Listener is mentioned

Here is my understanding

<!-- Sources -->
<Button x:Name="aButton" Click="MyHandler" />
or
<asp:Button ID="aButton" OnClick="MyHanlder" />

//handler
protected void MyHanlder(object source, EventArgs e)
{

}

From the documentation there is this statement under what is a Routed Event section

The event can invoke handlers on listeners at the element tree root, and then route to successive child elements along the tree node route towards the node element that is the event source

From the code I showed above I know these (Please correct me if am wrong):

The question is I could not understand what is the Event Listener here

Upvotes: 0

Views: 291

Answers (2)

Hogan
Hogan

Reputation: 70523

An event listener is just another name for the the event handler.

From the point of view object with the handler it has a handler.
(This object implements a handler.)

From the point of view of the object which is calling the listener it is a listener.
(This object invokes a listener.)

They are the same thing.

Upvotes: 1

JleruOHeP
JleruOHeP

Reputation: 10376

Event listner is an element in your layout, as it stated here: http://msdn.microsoft.com/en-us/library/ms742806.aspx

Routed event listeners and routed event sources do not need to share a common event in their hierarchy. Any UIElement or ContentElement can be an event listener for any routed event. Therefore, you can use the full set of routed events available throughout the working API set as a conceptual "interface" whereby disparate elements in the application can exchange event information. This "interface" concept for routed events is particularly applicable for input events.

Upvotes: 0

Related Questions