UIElement.RemoveHandler method

Expand Minimize
This topic has not yet been rated - Rate this topic

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

Syntax


public void RemoveHandler(
  RoutedEvent routedEvent, 
  object handler
)

Parameters

routedEvent

Type: RoutedEvent

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

handler

Type: System.Object [.NET] | Platform::Object [C++]

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.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.winmd

See also

AddHandler
UIElement
Events and routed events overview
RoutedEvent

 

 

Build date: 1/31/2013

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.