Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
System.Windows
EventManager Class
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 11/.NET Framework 4.5

Other versions are also available for the following:
.NET Framework Class Library
EventManager Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Provides event-related utility methods that register routed events for class owners and add class handlers.

System..::.Object
  System.Windows..::.EventManager

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
Visual Basic
Public NotInheritable Class EventManager
C#
public static class EventManager
Visual C++
public ref class EventManager abstract sealed
F#
[<AbstractClass>]
[<Sealed>]
type EventManager =  class end

The EventManager type exposes the following members.

  NameDescription
Public methodStatic memberGetRoutedEventsReturns identifiers for routed events that have been registered to the event system.
Public methodStatic memberGetRoutedEventsForOwnerFinds all routed event identifiers for events that are registered with the provided owner type.
Public methodStatic memberRegisterClassHandler(Type, RoutedEvent, Delegate)Registers a class handler for a particular routed event.
Public methodStatic memberRegisterClassHandler(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.
Public methodStatic memberRegisterRoutedEventRegisters a new routed event with the Windows Presentation Foundation (WPF) event system.
Top

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.

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.

Visual Basic
        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
C#
		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); }
		}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8 Release Preview, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker