UIElement.RemoveHandler Method (RoutedEvent, Delegate)
Removes the specified routed event handler from this element.
Assembly: PresentationCore (in PresentationCore.dll)
The identifier of the routed event for which the handler is attached.
The specific handler implementation to remove from the event handler collection on this element.
The most common scenario for using this API is when you implement the 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 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 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 AddHandler(RoutedEvent, Delegate, Boolean) signature that enables handling of already-handled events. Either type of handler is removed.
The following example usesas part of an event wrapper definition.
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
Available since 3.0
Available since 3.0
Windows Phone Silverlight
Available since 7.0