EventManager.RegisterRoutedEvent Method (String, RoutingStrategy, Type, Type)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Registers a new routed event with the Windows Presentation Foundation (WPF) event system.

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

public static RoutedEvent RegisterRoutedEvent(
	string name,
	RoutingStrategy routingStrategy,
	Type handlerType,
	Type ownerType


Type: System.String

The name of the routed event. The name must be unique within the owner type and cannot be null or an empty string.

Type: System.Windows.RoutingStrategy

The routing strategy of the event as a value of the enumeration.

Type: System.Type

The type of the event handler. This must be a delegate type and cannot be null.

Type: System.Type

The owner class type of the routed event. This cannot be null.

Return Value

Type: System.Windows.RoutedEvent

The identifier for the newly registered routed event. This identifier object can now be stored as a static field in a class and then used as a parameter for methods that attach handlers to the event. The routed event identifier is also used for other event system APIs.

Use the return value of this method to create the static declaration for a unique RoutedEvent identifier field. This field should be stored within the owner type.

There are a considerable number of conventions and best practices associated with how routed events should be named, registered, and exposed in a class. For more information, see Routed Events Overview.

.NET Framework
Available since 3.0
Return to top