EventManager.RegisterRoutedEvent(String, RoutingStrategy, Type, Type) Yöntem
Tanım
Olay sistemiyle yeni bir yönlendirilmiş olay kaydeder Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) .Registers a new routed event with the Windows Presentation Foundation (WPF)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
Parametreler
- name
- String
Yönlendirilmiş olayın adı.The name of the routed event. Ad, sahip türü içinde benzersiz olmalıdır ve null
boş bir dize olamaz.The name must be unique within the owner type and cannot be null
or an empty string.
- routingStrategy
- RoutingStrategy
Etkinliğin, numaralandırmanın bir değeri olarak yönlendirme stratejisi.The routing strategy of the event as a value of the enumeration.
- handlerType
- Type
Olay işleyicisinin türü.The type of the event handler. Bu bir temsilci türü olmalıdır ve olamaz null
.This must be a delegate type and cannot be null
.
- ownerType
- Type
Yönlendirilmiş olayın sahip sınıfı türü.The owner class type of the routed event. Bu, olamaz null
.This cannot be null
.
Döndürülenler
Yeni kaydedilmiş yönlendirilmiş olay için tanımlayıcı.The identifier for the newly registered routed event. Bu tanımlayıcı nesne artık bir sınıfta statik bir alan olarak depolanabilir ve sonra, olaya işleyiciler bağlayan yöntemler için bir parametre olarak kullanılabilir.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. Yönlendirilmiş olay tanımlayıcısı diğer olay sistemi API 'Leri için de kullanılır.The routed event identifier is also used for other event system APIs.
Açıklamalar
Benzersiz bir tanımlayıcı alanı için statik bildirim oluşturmak üzere bu yöntemin dönüş değerini kullanın RoutedEvent .Use the return value of this method to create the static declaration for a unique RoutedEvent identifier field. Bu alan, sahip türü içinde depolanmalıdır.This field should be stored within the owner type.
Yönlendirilmiş olayların adlandırılması, kaydedilmesi ve bir sınıfta kullanıma sunulmasıdır. Bu, çok sayıda kural ve en iyi yöntem vardır.There are a considerable number of conventions and best practices associated with how routed events should be named, registered, and exposed in a class. Daha fazla bilgi için bkz. yönlendirilmiş olaylara genel bakış.For more information, see Routed Events Overview.