EventManager.RegisterRoutedEvent Method

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

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

static member RegisterRoutedEvent : 
        name:string * 
        routingStrategy:RoutingStrategy * 
        handlerType:Type * 
        ownerType:Type -> RoutedEvent

Parameters

name
Type: System.String

The name of the routed event. The name must be unique within the owner type and cannot be a null reference (Nothing in Visual Basic) or an empty string.

routingStrategy
Type: System.Windows.RoutingStrategy

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

handlerType
Type: System.Type

The type of the event handler. This must be a delegate type and cannot be a null reference (Nothing in Visual Basic).

ownerType
Type: System.Type

The owner class type of the routed event. This cannot be a null reference (Nothing in Visual Basic).

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

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft