EventManager Clase

Definición

Proporciona métodos de utilidad relacionados con eventos que registran eventos enrutados para los propietarios de la clase y agregan controladores de clases.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
Herencia
EventManager

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar esta clase para registrar un nuevo evento enrutado como un miembro de clase, junto con la técnica de "contenedor" de eventos enrutados de invalidar las implementaciones de agregar y quitar para un evento CLR.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

Comentarios

Esta clase se usa normalmente para registrar un nuevo evento enrutado, con RegisterRoutedEvent .This class is most commonly used to register a new routed event, with RegisterRoutedEvent.

El segundo uso más común de la API es RegisterClassHandler .The second most common API usage is RegisterClassHandler. Este método se usa para habilitar el control de clases de un evento enrutado en la clase o un evento adjunto.You use this method to enable class handling of a routed event on the class, or an attached event. Para obtener más información, vea marcar eventos enrutados como controlados y control de clases.For details, see Marking Routed Events as Handled, and Class Handling.

Métodos

GetRoutedEvents()

Devuelve los identificadores de los eventos enrutados registrados en el sistema de eventos.Returns identifiers for routed events that have been registered to the event system.

GetRoutedEventsForOwner(Type)

Busca eventos en todos los identificadores de eventos enrutados con el tipo de propietario proporcionado.Finds all routed event identifiers for events that are registered with the provided owner type.

RegisterClassHandler(Type, RoutedEvent, Delegate)

Registra un controlador de clase de un evento enrutado concreto.Registers a class handler for a particular routed event.

RegisterClassHandler(Type, RoutedEvent, Delegate, Boolean)

Registra un controlador de clase de un evento enrutado concreto, con la opción de controlar los eventos en los que los datos del evento ya estén marcados como controlados.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)

Registra un nuevo evento enrutado con el sistema de eventos Windows Presentation Foundation (WPF).Registers a new routed event with the Windows Presentation Foundation (WPF) event system.

Se aplica a