/// <summary> /// Removes a handler for the CursorLeave event on a particular element /// </summary> /// <param name="target">The element to handle the event on</param> /// <param name="handler">The handler of the event</param> public static void RemoveCursorLeaveHandler(DependencyObject target, EventHandler <CursorEventArgs> handler) { IInputElement ie = target as IInputElement; if (ie != null) { ie.RemoveHandler(CursorLeaveEvent, handler); } }
private static void SetUpEventHandler(IInputElement element, RoutedEvent routedEvent, Delegate handler) { // // Setting NavigateUri causes navigation event handlers to be set up. // Doing this repeatedly would keep adding handlers; therefore remove any handler first. // element.RemoveHandler(routedEvent, handler); element.AddHandler(routedEvent, handler); }
/// <summary> /// Removes a handler for the specified event on the specified element /// </summary> /// <param name="element">The element that listens to the event</param> /// <param name="routedEvent">The event to unhook from</param> /// <param name="handler">The delegate to remove</param> public static void RemoveHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler) { if (element == null) { throw new ArgumentNullException("element"); } IInputElement inputElement = element as IInputElement; if (null != inputElement) { inputElement.RemoveHandler(routedEvent, handler); } }
private static void HandleContextMenuOpeningStatic(object sender, ContextMenuEventArgs e) { DependencyObject dObjSender = sender as DependencyObject; IInputElement inputElementSender = sender as IInputElement; if (dObjSender != null && inputElementSender != null) { ContextMenu contextMenu = (ContextMenu)(dObjSender.GetValue(FrameworkElement.ContextMenuProperty)); if (contextMenu == null) { TextSelectionSettings settings = TextSelection.GetSettings(dObjSender); IEnumerable <RoutedUICommand> commands = null; if (settings != null && settings.HasContextMenuCommands) { commands = settings.ContextMenuCommands; } else { commands = TextSelectionSettings.DefaultContextMenuCommands; } contextMenu = CreateContextMenu(inputElementSender, commands); if (contextMenu != null) { // We are repacing a null ContextMenu with our built from scratch ContextMenu. // Mark the event as handled so that the built in context menu service does not // try to open the null Context menu and we can open our built from scratch menu // ourselves e.Handled = true; RoutedEventHandler handleContextMenuClosed = null; handleContextMenuClosed = (closedSender, closedArgs) => { inputElementSender.RemoveHandler(FrameworkElement.ContextMenuClosingEvent, handleContextMenuClosed); dObjSender.ClearValue(FrameworkElement.ContextMenuProperty); }; inputElementSender.AddHandler(FrameworkElement.ContextMenuClosingEvent, handleContextMenuClosed); dObjSender.SetValue(FrameworkElement.ContextMenuProperty, contextMenu); contextMenu.IsOpen = true; } } } }
/// <summary> /// Stops listening for the Enter key when the button is no longer <see cref="IsDefault"/>. /// </summary> /// <param name="root">The input root.</param> private void StopListeningForDefault(IInputElement root) { root.RemoveHandler(KeyDownEvent, RootKeyDown); }
/// <summary> /// Stops listening for the Enter key when the button is no longer <see cref="IsDefault"/>. /// </summary> /// <param name="root">The input root.</param> private void StopListeningForDefault(IInputElement root) { root.RemoveHandler(InputElement.KeyDownEvent, this.RootKeyDown); }
/// <summary> /// Stops listening for the Escape key when the button is no longer <see cref="IsCancel"/>. /// </summary> /// <param name="root">The input root.</param> private void StopListeningForCancel(IInputElement root) { root.RemoveHandler(KeyDownEvent, RootCancelKeyDown); }
// Token: 0x0600304E RID: 12366 RVA: 0x000D90A4 File Offset: 0x000D72A4 private static void SetUpEventHandler(IInputElement element, RoutedEvent routedEvent, Delegate handler) { element.RemoveHandler(routedEvent, handler); element.AddHandler(routedEvent, handler); }
private static void SetUpEventHandler(IInputElement element, RoutedEvent routedEvent, Delegate handler) { // // Setting NavigateUri causes navigation event handlers to be set up. // Doing this repeatedly would keep adding handlers; therefore remove any handler first. // element.RemoveHandler(routedEvent, handler); element.AddHandler(routedEvent, handler); }
public static Action Enhance(this IInputElement element, DispatchEventHandler handler) { element.AddHandler(FluxAction.DispatchEvent, handler); return(() => element.RemoveHandler(FluxAction.DispatchEvent, handler)); }