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

Definition

Removes the specified routed event handler from this UIElement. Typically the handler in question was added by AddHandler.

public : void RemoveHandler(RoutedEvent routedEvent, Platform::Object handler)
void RemoveHandler(RoutedEvent routedEvent, winrt::Windows::Foundation::IInspectable handler) const;
public void RemoveHandler(RoutedEvent routedEvent, Object handler)
Public Sub RemoveHandler(routedEvent As RoutedEvent, handler As Object)

Parameters

routedEvent
RoutedEvent RoutedEvent

The identifier of the routed event for which the handler is attached.

handler
Object Object

The specific handler implementation to remove from the event handler collection on this UIElement.

Remarks

RemoveHandler can only be used for the event handlers of the events that are supported by AddHandler, which is approximately the input-specific events of UIElement. More precisely, the event must have a **Event* property of type RoutedEvent, which is true only of certain events on UIElement. You cannot use RemoveHandler to unhook event handlers for Windows Runtime events on runtime class instances in general. Instead, you should use the specific event handler unhooking syntax:

  • -= in C#
  • RemoveHandler in Microsoft Visual Basic
  • -= in Visual C++ component extensions (C++/CX)

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

This method ignores whether handledEventsToo parameter was true in the AddHandler call that originally attached the handler.

See Also