本文整理汇总了C#中System.Windows.UIElement.RemoveHandler方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.RemoveHandler方法的具体用法?C# UIElement.RemoveHandler怎么用?C# UIElement.RemoveHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.UIElement
的用法示例。
在下文中一共展示了UIElement.RemoveHandler方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveEvent
/// <summary>
/// 注销事件
/// </summary>
/// <param name="element"></param>
public void RemoveEvent(UIElement element)
{
if (element != null)
{
element.RemoveHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(ElementMouseDown));
}
}
示例2: RemoveRoutedEventHandlers
/// <summary>
/// Removes all event handlers subscribed to the specified routed event from the specified element.
/// See http://stackoverflow.com/questions/6828054
/// </summary>
/// <param name="element">The UI element on which the routed event is defined.</param>
/// <param name="routedEvent">The routed event for which to remove the event handlers.</param>
public static void RemoveRoutedEventHandlers(UIElement element, RoutedEvent routedEvent)
{
// Get the EventHandlersStore instance which holds event handlers for the specified element.
// The EventHandlersStore class is declared as internal.
var eventHandlersStoreProperty = typeof(UIElement).GetProperty("EventHandlersStore",
BindingFlags.Instance | BindingFlags.NonPublic);
object eventHandlersStore = eventHandlersStoreProperty.GetValue(element, null);
// Invoke the GetRoutedEventHandlers method on the EventHandlersStore instance
// for getting an array of the subscribed event handlers.
var getRoutedEventHandlers = eventHandlersStore.GetType().GetMethod("GetRoutedEventHandlers",
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
var routedEventHandlers = (RoutedEventHandlerInfo[])getRoutedEventHandlers.Invoke(
eventHandlersStore, new object[] { routedEvent });
// Iteratively remove all routed event handlers from the element.
if (routedEventHandlers != null && routedEventHandlers.Length != 0)
foreach (var routedEventHandler in routedEventHandlers)
element.RemoveHandler(routedEvent, routedEventHandler.Handler);
}
示例3: RemoveQueryInteractionStatusHandler
/// <summary>
/// Removes a handler for the QueryGripInteractionStatus attached event
/// </summary>
/// <param name="element">UIElement that listens to this event</param>
/// <param name="handler">Event Handler to be removed</param>
public static void RemoveQueryInteractionStatusHandler(UIElement element, EventHandler<QueryInteractionStatusEventArgs> handler)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.RemoveHandler(KinectRegion.QueryInteractionStatusEvent, handler);
}
示例4: RemoveHandPointerLostCaptureHandler
/// <summary>
/// Removes a handler for the HandPointerLostCapture attached event
/// </summary>
/// <param name="element">UIElement that listens to this event</param>
/// <param name="handler">Event Handler to be removed</param>
public static void RemoveHandPointerLostCaptureHandler(UIElement element, EventHandler<HandPointerEventArgs> handler)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
element.RemoveHandler(KinectRegion.HandPointerLostCaptureEvent, handler);
}
示例5: RemoveClearPropertyItemHandler
/// <summary>
/// Removes a handler for the ClearPropertyItem attached event
/// </summary>
/// <param name="element">the element to attach the handler</param>
/// <param name="handler">the handler for the event</param>
public static void RemoveClearPropertyItemHandler( UIElement element, PropertyItemEventHandler handler )
{
element.RemoveHandler( PropertyGrid.ClearPropertyItemEvent, handler );
}
示例6: RemovePreviewExecutedHandler
/// <summary>
/// Removes the handler from the element.
/// </summary>
/// <param name="element">The element from which to remove the handler.</param>
/// <param name="handler">The handler to remove.</param>
public static void RemovePreviewExecutedHandler(UIElement element, ExecutedRoutedEventHandler handler)
{
if (element == null)
{
throw new ArgumentNullException("element");
}
if (handler == null)
{
throw new ArgumentNullException("handler");
}
element.RemoveHandler(PreviewExecutedEvent, handler);
}