UIElement.RemoveHandler(RoutedEvent, Delegate) UIElement.RemoveHandler(RoutedEvent, Delegate) UIElement.RemoveHandler(RoutedEvent, Delegate) Method

Definición

Quita el controlador de eventos enrutados especificado de este elemento.Removes the specified routed event handler from this element.

public:
 virtual void RemoveHandler(System::Windows::RoutedEvent ^ routedEvent, Delegate ^ handler);
public void RemoveHandler (System.Windows.RoutedEvent routedEvent, Delegate handler);
abstract member RemoveHandler : System.Windows.RoutedEvent * Delegate -> unit
override this.RemoveHandler : System.Windows.RoutedEvent * Delegate -> unit

Parámetros

routedEvent
RoutedEvent RoutedEvent RoutedEvent

Identificador del evento enrutado al que se adjunta el controlador.The identifier of the routed event for which the handler is attached.

handler
Delegate Delegate Delegate

Implementación de controlador específica que se va a quitar de la colección de controladores de eventos de este elemento.The specific handler implementation to remove from the event handler collection on this element.

Implementaciones

Ejemplos

En el ejemplo siguiente RemoveHandler se usa como parte de una definición de contenedor de eventos.The following example uses RemoveHandler as part of an event wrapper definition.

public static readonly RoutedEvent TapEvent = EventManager.RegisterRoutedEvent(
    "Tap", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyButtonSimple));

// Provide CLR accessors for the event
public event RoutedEventHandler Tap
{
        add { AddHandler(TapEvent, value); } 
        remove { RemoveHandler(TapEvent, value); }
}
Public Shared ReadOnly TapEvent As RoutedEvent = EventManager.RegisterRoutedEvent("Tap", RoutingStrategy.Bubble, GetType(RoutedEventHandler), GetType(MyButtonSimple))

' Provide CLR accessors for the event
Public Custom Event Tap As RoutedEventHandler
    AddHandler(ByVal value As RoutedEventHandler)
        Me.AddHandler(TapEvent, value)
    End AddHandler

    RemoveHandler(ByVal value As RoutedEventHandler)
        Me.RemoveHandler(TapEvent, value)
    End RemoveHandler

    RaiseEvent(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Me.RaiseEvent(e)
    End RaiseEvent
End Event

Comentarios

El escenario más común para usar esto APIAPI es cuando se implementa el Common Language Runtime (CLR)common language runtime (CLR) evento "contenedor" que está asociado a un evento enrutado personalizado, específicamente cuando se implementa la lógica "quitar" para los controladores en CLRCLR el nivel.The most common scenario for using this APIAPI is when you implement the Common Language Runtime (CLR)common language runtime (CLR) "wrapper" event that is associated with a custom routed event, specifically when you implement the "remove" logic for handlers at the CLRCLR level. En el ejemplo siguiente se muestra este escenario.The example that follows this remarks section illustrates this scenario.

Llamar a este método no tiene ningún efecto si no hay controladores registrados con criterios que coincidan con los parámetros de entrada de la llamada al método.Calling this method has no effect if there were no handlers registered with criteria that matches the input parameters for the method call.

Si hay más de un controlador asociado que coincida con los criterios, solo se quita el primer controlador del almacén de controladores de eventos.If more than one handler is attached that matched the criteria, only the first handler in the event handler store is removed. Este comportamiento es coherente con CLRCLR el -= comportamiento del operador.This behavior is consistent with CLRCLR behavior of the -= operator.

Ni routedEvent ni handler pueden ser null.Neither routedEvent nor handler may be null. Si se intenta proporcionar cualquier valor como null , se producirá una excepción.Attempting to provide either value as null will raise an exception.

Este método omite la información handledEventsToo de parámetros, que se proporciona si el controlador se agregó por primera vez AddHandler(RoutedEvent, Delegate, Boolean) con la firma que habilita el control de eventos ya controlados.This method ignores the handledEventsToo parameter information, which is provided if the handler was first added with the AddHandler(RoutedEvent, Delegate, Boolean) signature that enables handling of already-handled events. Se quita cualquier tipo de controlador.Either type of handler is removed.

Se aplica a

Consulte también: