Export (0) Print
Expand All
Expand Minimize

RoutedEventHandler Delegate

Represents the delegate for handlers that receive routed events.

Namespace: System.Windows
Assembly: PresentationCore (in presentationcore.dll)

public delegate void RoutedEventHandler (
	Object sender,
	RoutedEventArgs e
)
/** @delegate */
public delegate void RoutedEventHandler (
	Object sender, 
	RoutedEventArgs e
)
In XAML, you can use delegates but you cannot define your own.

Parameters

sender

The element where the handler is being invoked.

e

RoutedEventArgs event arguments that contain information about the routed event, including the event source element.

The RoutedEventHandler delegate is used for any routed event that does not report event-specific information in the event data.

This example shows how to find the source element in an event handler.

The following example shows a Click event handler that is declared in a code-behind file. When a user clicks the button that the handler is attached to, the handler changes a property value. The handler code uses the Source property of the routed event data that is reported in the event arguments to change the Width property value on the Source element.

<Button Click="HandleClick">Button 1</Button>

void HandleClick(object sender, RoutedEventArgs e)
{
    // You must cast the sender object as a Button element, or at least as FrameworkElement, to set Width
    Button srcButton = e.Source as Button;
    srcButton.Width = 200;
}

For the complete sample, see Finding the Source Element in an Event Handler Sample.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft