Dela via


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:
 virtual void RemoveHandler(RoutedEvent ^ routedEvent, Platform::Object ^ handler) = RemoveHandler;
void RemoveHandler(RoutedEvent const& routedEvent, IInspectable const& handler);
public void RemoveHandler(RoutedEvent routedEvent, object handler);
function removeHandler(routedEvent, handler)
Public Sub RemoveHandler (routedEvent As RoutedEvent, handler As Object)

Parameters

routedEvent
RoutedEvent

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

handler
Object

Platform::Object

IInspectable

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.

Applies to

See also