แก้ไข

แชร์ผ่าน


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

Definition

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

public:
 static System::Windows::RoutedEvent ^ RegisterRoutedEvent(System::String ^ name, System::Windows::RoutingStrategy routingStrategy, Type ^ handlerType, Type ^ ownerType);
public static System.Windows.RoutedEvent RegisterRoutedEvent (string name, System.Windows.RoutingStrategy routingStrategy, Type handlerType, Type ownerType);
static member RegisterRoutedEvent : string * System.Windows.RoutingStrategy * Type * Type -> System.Windows.RoutedEvent
Public Shared Function RegisterRoutedEvent (name As String, routingStrategy As RoutingStrategy, handlerType As Type, ownerType As Type) As RoutedEvent

Parameters

name
String

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

routingStrategy
RoutingStrategy

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

handlerType
Type

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

ownerType
Type

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

Returns

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.

Remarks

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.

Applies to