private static void OnOverflowOpenChanged(DependencyObject element, DependencyPropertyChangedEventArgs e) { ToolBar toolBar = (ToolBar)element; if ((bool)e.NewValue) { // When the drop down opens, take capture Mouse.Capture(toolBar, CaptureMode.SubTree); toolBar.SetFocusOnToolBarOverflowPanel(); } else { // If focus is still within the ToolBarOverflowPanel, make sure we the focus is restored to the main focus scope ToolBarOverflowPanel overflow = toolBar.ToolBarOverflowPanel; if (overflow != null && overflow.IsKeyboardFocusWithin) { Keyboard.Focus(null); } if (Mouse.Captured == toolBar) { Mouse.Capture(null); } } toolBar.CoerceValue(ToolTipService.IsEnabledProperty); }
/// <summary> /// This is the method that responds to the KeyDown event. /// </summary> /// <param name="e"></param> protected override void OnKeyDown(KeyEventArgs e) { UIElement newFocusElement = null; UIElement currentFocusElement = e.Source as UIElement; if (currentFocusElement != null && ItemsControl.ItemsControlFromItemContainer(currentFocusElement) == this) { // itemsHost should be either ToolBarPanel or ToolBarOverflowPanel Panel itemsHost = VisualTreeHelper.GetParent(currentFocusElement) as Panel; if (itemsHost != null) { switch (e.Key) { // itemsHost.Children.Count is greater than zero because itemsHost is visual parent of currentFocusElement case Key.Home: newFocusElement = VisualTreeHelper.GetChild(itemsHost, 0) as UIElement; break; case Key.End: newFocusElement = VisualTreeHelper.GetChild(itemsHost, VisualTreeHelper.GetChildrenCount(itemsHost) - 1) as UIElement; break; case Key.Escape: { // If focus is within ToolBarOverflowPanel - move focus the the toggle button ToolBarOverflowPanel overflow = ToolBarOverflowPanel; if (overflow != null && overflow.IsKeyboardFocusWithin) { MoveFocus(new TraversalRequest(FocusNavigationDirection.Last)); } else { Keyboard.Focus(null); } // Close the overflow the Esc is pressed Close(); } break; } if (newFocusElement != null) { if (newFocusElement.Focus()) { e.Handled = true; } } } } if (!e.Handled) { base.OnKeyDown(e); } }
private ToolBarOverflowPanel FindToolBarOverflowPanel() { DependencyObject child = GetTemplateChild(ToolBarOverflowPanelTemplateName); ToolBarOverflowPanel toolBarOverflowPanel = child as ToolBarOverflowPanel; if (child != null && toolBarOverflowPanel == null) { throw new NotSupportedException(SR.Get(SRID.ToolBar_InvalidStyle_ToolBarOverflowPanel, child.GetType())); } return(toolBarOverflowPanel); }
// Token: 0x06005830 RID: 22576 RVA: 0x00186C00 File Offset: 0x00184E00 private ToolBarOverflowPanel FindToolBarOverflowPanel() { DependencyObject templateChild = base.GetTemplateChild("PART_ToolBarOverflowPanel"); ToolBarOverflowPanel toolBarOverflowPanel = templateChild as ToolBarOverflowPanel; if (templateChild != null && toolBarOverflowPanel == null) { throw new NotSupportedException(SR.Get("ToolBar_InvalidStyle_ToolBarOverflowPanel", new object[] { templateChild.GetType() })); } return(toolBarOverflowPanel); }
/// <summary>Provides class handling for the <see cref="E:System.Windows.UIElement.KeyDown" /> routed event that occurs when a key is pressed on an item in the <see cref="T:System.Windows.Controls.ToolBar" />. </summary> /// <param name="e">The arguments for the <see cref="E:System.Windows.UIElement.KeyDown" /> event.</param> // Token: 0x06005831 RID: 22577 RVA: 0x00186C48 File Offset: 0x00184E48 protected override void OnKeyDown(KeyEventArgs e) { UIElement uielement = null; UIElement uielement2 = e.Source as UIElement; if (uielement2 != null && ItemsControl.ItemsControlFromItemContainer(uielement2) == this) { Panel panel = VisualTreeHelper.GetParent(uielement2) as Panel; if (panel != null) { Key key = e.Key; if (key != Key.Escape) { if (key != Key.End) { if (key == Key.Home) { uielement = (VisualTreeHelper.GetChild(panel, 0) as UIElement); } } else { uielement = (VisualTreeHelper.GetChild(panel, VisualTreeHelper.GetChildrenCount(panel) - 1) as UIElement); } } else { ToolBarOverflowPanel toolBarOverflowPanel = this.ToolBarOverflowPanel; if (toolBarOverflowPanel != null && toolBarOverflowPanel.IsKeyboardFocusWithin) { this.MoveFocus(new TraversalRequest(FocusNavigationDirection.Last)); } else { Keyboard.Focus(null); } this.Close(); } if (uielement != null && uielement.Focus()) { e.Handled = true; } } } if (!e.Handled) { base.OnKeyDown(e); } }
private void SetFocusOnToolBarOverflowPanel() { Dispatcher.BeginInvoke(DispatcherPriority.Input, new DispatcherOperationCallback(delegate(object param) { if (ToolBarOverflowPanel != null) { // If the overflow is opened by keyboard - focus the first item // otherwise - set focus on the panel itself if (KeyboardNavigation.IsKeyboardMostRecentInputDevice()) { ToolBarOverflowPanel.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next)); } else { ToolBarOverflowPanel.Focus(); } } return(null); }), null); }
// Token: 0x0600581D RID: 22557 RVA: 0x001867C0 File Offset: 0x001849C0 private static void OnOverflowOpenChanged(DependencyObject element, DependencyPropertyChangedEventArgs e) { ToolBar toolBar = (ToolBar)element; if ((bool)e.NewValue) { Mouse.Capture(toolBar, CaptureMode.SubTree); toolBar.SetFocusOnToolBarOverflowPanel(); } else { ToolBarOverflowPanel toolBarOverflowPanel = toolBar.ToolBarOverflowPanel; if (toolBarOverflowPanel != null && toolBarOverflowPanel.IsKeyboardFocusWithin) { Keyboard.Focus(null); } if (Mouse.Captured == toolBar) { Mouse.Capture(null); } } toolBar.CoerceValue(ToolTipService.IsEnabledProperty); }
public static IObservable <EventPattern <MouseButtonEventArgs> > PreviewMouseUpObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.PreviewMouseUp += h, h => This.PreviewMouseUp -= h)); }
public static IObservable <EventPattern <ToolTipEventArgs> > ToolTipClosingObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <ToolTipEventHandler, ToolTipEventArgs>(h => This.ToolTipClosing += h, h => This.ToolTipClosing -= h)); }
public static IObservable <EventPattern <ManipulationBoundaryFeedbackEventArgs> > ManipulationBoundaryFeedbackObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <EventHandler <ManipulationBoundaryFeedbackEventArgs>, ManipulationBoundaryFeedbackEventArgs>(h => This.ManipulationBoundaryFeedback += h, h => This.ManipulationBoundaryFeedback -= h)); }
public static IObservable <EventPattern <DependencyPropertyChangedEventArgs> > FocusableChangedObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <DependencyPropertyChangedEventHandler, DependencyPropertyChangedEventArgs>(h => This.FocusableChanged += h, h => This.FocusableChanged -= h)); }
public static IObservable <EventPattern <EventArgs> > LayoutUpdatedObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <EventHandler, EventArgs>(h => This.LayoutUpdated += h, h => This.LayoutUpdated -= h)); }
public static IObservable <EventPattern <TouchEventArgs> > TouchLeaveObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.TouchLeave += h, h => This.TouchLeave -= h)); }
public static IObservable <EventPattern <KeyEventArgs> > PreviewKeyDownObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <KeyEventHandler, KeyEventArgs>(h => This.PreviewKeyDown += h, h => This.PreviewKeyDown -= h)); }
public static IObservable <EventPattern <RequestBringIntoViewEventArgs> > RequestBringIntoViewObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <RequestBringIntoViewEventHandler, RequestBringIntoViewEventArgs>(h => This.RequestBringIntoView += h, h => This.RequestBringIntoView -= h)); }
public static IObservable <EventPattern <DragEventArgs> > DropObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.Drop += h, h => This.Drop -= h)); }
public static IObservable <EventPattern <TouchEventArgs> > PreviewTouchUpObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.PreviewTouchUp += h, h => This.PreviewTouchUp -= h)); }
public static IObservable <EventPattern <KeyEventArgs> > KeyUpObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <KeyEventHandler, KeyEventArgs>(h => This.KeyUp += h, h => This.KeyUp -= h)); }
public static IObservable <EventPattern <RoutedEventArgs> > UnloadedObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.Unloaded += h, h => This.Unloaded -= h)); }
public static IObservable <EventPattern <KeyboardFocusChangedEventArgs> > PreviewLostKeyboardFocusObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <KeyboardFocusChangedEventHandler, KeyboardFocusChangedEventArgs>(h => This.PreviewLostKeyboardFocus += h, h => This.PreviewLostKeyboardFocus -= h)); }
public static IObservable <EventPattern <RoutedEventArgs> > LostFocusObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.LostFocus += h, h => This.LostFocus -= h)); }
public static IObservable <EventPattern <SizeChangedEventArgs> > SizeChangedObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <SizeChangedEventHandler, SizeChangedEventArgs>(h => This.SizeChanged += h, h => This.SizeChanged -= h)); }
public static IObservable <EventPattern <ManipulationInertiaStartingEventArgs> > ManipulationInertiaStartingObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <EventHandler <ManipulationInertiaStartingEventArgs>, ManipulationInertiaStartingEventArgs>(h => This.ManipulationInertiaStarting += h, h => This.ManipulationInertiaStarting -= h)); }
public static IObservable <EventPattern <TextCompositionEventArgs> > TextInputObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <TextCompositionEventHandler, TextCompositionEventArgs>(h => This.TextInput += h, h => This.TextInput -= h)); }
public static IObservable <EventPattern <ManipulationCompletedEventArgs> > ManipulationCompletedObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <EventHandler <ManipulationCompletedEventArgs>, ManipulationCompletedEventArgs>(h => This.ManipulationCompleted += h, h => This.ManipulationCompleted -= h)); }
public static IObservable <EventPattern <QueryContinueDragEventArgs> > QueryContinueDragObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <QueryContinueDragEventHandler, QueryContinueDragEventArgs>(h => This.QueryContinueDrag += h, h => This.QueryContinueDrag -= h)); }
public static IObservable <EventPattern <ContextMenuEventArgs> > ContextMenuClosingObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <ContextMenuEventHandler, ContextMenuEventArgs>(h => This.ContextMenuClosing += h, h => This.ContextMenuClosing -= h)); }
public static IObservable <EventPattern <GiveFeedbackEventArgs> > GiveFeedbackObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <GiveFeedbackEventHandler, GiveFeedbackEventArgs>(h => This.GiveFeedback += h, h => This.GiveFeedback -= h)); }
public static IObservable <EventPattern <MouseButtonEventArgs> > MouseLeftButtonDownObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.MouseLeftButtonDown += h, h => This.MouseLeftButtonDown -= h)); }
public static IObservable <EventPattern <DragEventArgs> > PreviewDragLeaveObserver(this ToolBarOverflowPanel This) { return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.PreviewDragLeave += h, h => This.PreviewDragLeave -= h)); }