EventManager.RegisterClassHandler Method (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.
Assembly: PresentationCore (in PresentationCore.dll)
public static void RegisterClassHandler( Type classType, RoutedEvent routedEvent, Delegate handler, bool handledEventsToo )
- Type: System.Type
The type of the class that is declaring class handling.
- Type: System.Windows.RoutedEvent
The routed event identifier of the event to handle.
- Type: System.Delegate
A reference to the class handler implementation.
- Type: System.Boolean
true 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.
Class handling is a feature that is available for routed events, including attached events that are implemented with routed event backing. A class handler is like a static handler that exists for all instances of the class. Because the handler is static, you cannot change instance properties directly with a class handler, but you can access instances through the sender parameter and/or the event data.
Class handlers are invoked before instance handlers. You can implement a class handler that has the behavior of marking the event as handled. Therefore, instance handlers for a class-handled event are not invoked unless the instance handlers register specifically for handled events.
Many of the WPF base element events provide class handling virtual methods. By overriding these methods in classes that inherit the base classes, you can implement class handling without calling RegisterClassHandler in static constructors. These class handling methods typically exist for input events and have names that start with "On" and end with the name of the event being class handled.
For more information about class handling, see Marking Routed Events as Handled, and Class Handling.
Using this signature, class handlers can be registered to invoke upon handled events, by setting handledEventsToo set to true. Generally, you should do this only if there is a known handling issue you are trying to work around, such as input system handling from mouse or keyboard events.