Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.

Método UIElement.RemoveHandler (RoutedEvent, Delegate)


Remove o manipulador de eventos roteados especificado desse elemento.

Namespace:   System.Windows
Assembly:  PresentationCore (em PresentationCore.dll)

public void RemoveHandler(
	RoutedEvent routedEvent,
	Delegate handler


Type: System.Windows.RoutedEvent

O identificador do evento roteado ao qual o manipulador está anexado.

Type: System.Delegate

A implementação do manipulador específico para remover da coleção de manipuladores de eventos neste elemento.

The most common scenario for using this TLA#tla_api is when you implement the TLA#tla_clr "wrapper" event that is associated with a custom routed event, specifically when you implement the "remove" logic for handlers at the TLA2#tla_clr level. The example that follows this remarks section illustrates this scenario.

Calling this method has no effect if there were no handlers registered with criteria that matches the input parameters for the method call.

If more than one handler is attached that matched the criteria, only the first handler in the event handler store is removed. This behavior is consistent with TLA2#tla_clr behavior of the -= operator.

Neither routedEvent nor handler may be null. Attempting to provide either value as null will raise an exception.

This method ignores the handledEventsToo parameter information, which is provided if the handler was first added with the M:System.Windows.UIElement.AddHandler(System.Windows.RoutedEvent,System.Delegate,System.Boolean) signature that enables handling of already-handled events. Either type of handler is removed.

The following example uses M:System.Windows.UIElement.RemoveHandler(System.Windows.RoutedEvent,System.Delegate) 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); }

.NET Framework
Disponível desde 3.0
Disponível desde 3.0
Windows Phone Silverlight
Disponível desde 7.0
Retornar ao início