EventManager.RegisterRoutedEvent(String, RoutingStrategy, Type, Type) 方法

定義

向WINDOWS PRESENTATION FOUNDATION (WPF) 事件系統註冊新的路由事件。

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

參數

name
String

路由事件的名稱。 名稱在擁有者類型內必須唯一,且不能是 null 或空字串。

routingStrategy
RoutingStrategy

作為列舉值的事件路由策略。

handlerType
Type

事件處理常式的類型。 這必須是委派類型,而且不能是 null

ownerType
Type

路由事件的擁有者類別類型。 不可為 null

傳回

RoutedEvent

新註冊路由事件的識別項。 這個識別項物件現在可以儲存為類別中的靜態欄位,然後作為附加至事件處理常式之方法的參數。 路由事件識別項也用於其他事件系統 API。

備註

使用這個方法的傳回值來建立唯 RoutedEvent 一識別碼欄位的靜態宣告。 此欄位應該儲存在擁有者類型內。

與路由事件在類別中命名、註冊和公開的方式相關,有相當多的慣例和最佳做法。 如需詳細資訊,請參閱 路由事件概觀

適用於