EventManager.RegisterRoutedEvent(String, RoutingStrategy, Type, Type) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
向 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不能。
返回
新注册的路由事件的标识符。 此标识符对象现在可以作为静态字段存储在类中,然后用作将处理程序附加到事件的方法的参数。 路由事件标识符也用于其他事件系统 API。
注解
使用此方法的返回值为唯 RoutedEvent 一标识符字段创建静态声明。 此字段应存储在所有者类型中。
与如何在类中命名、注册和公开路由事件相关的约定和最佳做法相当多。 有关详细信息,请参阅 路由事件概述。