Class EventManager
Provides event-related utility methods that register routed events for class owners and add class handlers.
public static class EventManager
- Inheritance
-
EventManager
Methods
GetRoutedEvent(Type, string)
Finds the routed event identified by its name and owner.
public static RoutedEvent GetRoutedEvent(Type ownerType, string eventName)
Parameters
ownerTypeTypeThe type to start the search with. Base classes are included in the search.
eventNamestringThe event name.
Returns
- RoutedEvent
The matching routed event identifier if any match is found; otherwise, null.
GetRoutedEvents()
Returns identifiers for routed events that have been registered to the event system.
public static RoutedEvent[] GetRoutedEvents()
Returns
- RoutedEvent[]
An array of type RoutedEvent that contains the registered objects.
GetRoutedEventsForOwner(Type)
Finds all routed event identifiers for events that are registered with the provided owner type.
public static RoutedEvent[] GetRoutedEventsForOwner(Type ownerType)
Parameters
ownerTypeTypeThe type to start the search with. Base classes are included in the search.
Returns
- RoutedEvent[]
An array of matching routed event identifiers if any match is found; otherwise, null.
RegisterClassHandler<T>(Type, RoutedEvent<T>, EventHandler<T>, bool)
Registers a class handler for a particular routed event, with the option to handle events where event data is already marked handled.
public static void RegisterClassHandler<T>(Type classType, RoutedEvent<T> routedEvent, EventHandler<T> handler, bool handledEventsToo = false) where T : RoutedEventArgs
Parameters
classTypeTypeThe type of the class that is declaring class handling.
routedEventRoutedEvent<T>The routed event identifier of the event to handle.
handlerEventHandler<T>A reference to the class handler implementation.
handledEventsToobooltrue to invoke this class handler even if arguments of the routed event have been marked as handled; false to retain the default behavior of not invoking the handler on any marked-handled event.
Type Parameters
T
Exceptions
- ArgumentNullException
classType,routedEvent, orhandleris null.
RegisterRoutedEvent<T>(string, RoutingStrategy, Type)
Registers a new routed event.
public static RoutedEvent<T> RegisterRoutedEvent<T>(string name, RoutingStrategy routingStrategy, Type ownerType) where T : RoutedEventArgs
Parameters
namestringThe name of the routed event. The name must be unique within the owner type (base class included) and cannot be null or an empty string.
routingStrategyRoutingStrategyThe routing strategy of the event as a value of the enumeration.
ownerTypeTypeThe owner class type of the routed event. This cannot be null.
Returns
- RoutedEvent<T>
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.
Type Parameters
T
Exceptions
- ArgumentNullException
nameorownerTypeis null.- InvalidOperationException
This exception is thrown if a routed event of name
namealready exists for typeownerTypeand parents.