Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

RoutedEventHandler Delegate

Represents the method that will handle routed events.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)
public delegate void RoutedEventHandler(
	Object sender,
	RoutedEventArgs e
)

Parameters

sender
Type: System.Object
The object where the event handler is attached.
e
Type: System.Windows.RoutedEventArgs
The event data.

The RoutedEventHandler delegate is used for any routed event that does not report event-specific information in the event data. There are many such routed events; prominent examples include Loaded.

The most noteworthy difference between writing a handler for a routed event as opposed to a general CLR event is that the sender of the event (the element where the handler is attached and invoked) cannot be considered to necessarily be the source of the event. The source is reported as a property in the event data (OriginalSource). A difference between sender and OriginalSource is the result of the event being routed to different elements, during the traversal of the routed event through an element tree.

You can use either sender or OriginalSource for an object reference if you are deliberately not interested in the routing behavior of a direct or bubbling routed event and you only intend to handle routed events on the elements where they are first raised. In this circumstance, sender and OriginalSource are the same object.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.