EventManager Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides event-related utility methods that register routed events for class owners and add class handlers.
public ref class EventManager abstract sealed
public static class EventManager
type EventManager = class
Public Class EventManager
- Inheritance
-
EventManager
Examples
The following example show how to use this class to register a new routed event as a class member, along with the routed event "wrapper" technique of overriding the add and remove implementations for a CLR event.
public static readonly RoutedEvent ButtonColorChangedEvent = EventManager.RegisterRoutedEvent("ButtonColorChanged",RoutingStrategy.Bubble,typeof(DependencyPropertyChangedEventHandler),typeof(Shirt));
public event RoutedEventHandler ButtonColorChanged {
add {AddHandler(ButtonColorChangedEvent,value);}
remove { RemoveHandler(ButtonColorChangedEvent, value); }
}
Public Shared ReadOnly ButtonColorChangedEvent As RoutedEvent = EventManager.RegisterRoutedEvent("ButtonColorChanged",RoutingStrategy.Bubble,GetType(DependencyPropertyChangedEventHandler),GetType(Shirt))
Public Custom Event ButtonColorChanged As RoutedEventHandler
AddHandler(ByVal value As RoutedEventHandler)
MyBase.AddHandler(ButtonColorChangedEvent,value)
End AddHandler
RemoveHandler(ByVal value As RoutedEventHandler)
MyBase.RemoveHandler(ButtonColorChangedEvent, value)
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As RoutedEventArgs)
End RaiseEvent
End Event
Remarks
This class is most commonly used to register a new routed event, with RegisterRoutedEvent.
The second most common API usage is RegisterClassHandler. You use this method to enable class handling of a routed event on the class, or an attached event. For details, see Marking Routed Events as Handled, and Class Handling.
Methods
GetRoutedEvents() |
Returns identifiers for routed events that have been registered to the event system. |
GetRoutedEventsForOwner(Type) |
Finds all routed event identifiers for events that are registered with the provided owner type. |
RegisterClassHandler(Type, RoutedEvent, Delegate) |
Registers a class handler for a particular routed event. |
RegisterClassHandler(Type, RoutedEvent, Delegate, Boolean) |
Registers a class handler for a particular routed event, with the option to handle events where event data is already marked handled. |
RegisterRoutedEvent(String, RoutingStrategy, Type, Type) |
Registers a new routed event with the Windows Presentation Foundation (WPF) event system. |
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기