/// <summary> /// Processes the <see cref="PopupOpeningEvent"/> event. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">A <c>CancelRoutedEventArgs</c> that contains the event data.</param> private static void OnPopupOpeningEvent(object sender, CancelRoutedEventArgs e) { RibbonControls.PopupButton popupButton = e.OriginalSource as RibbonControls.PopupButton; if (popupButton is RibbonControls.Primitives.QuickAccessToolBarCustomizeButton) { RibbonControls.Menu menu = popupButton.PopupContent as RibbonControls.Menu; if (menu != null) { MainControl.AddCustomMenuItem(popupButton, menu); } } }
///////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Creates a context menu for the specified <see cref="FrameworkElement"/>. /// </summary> /// <param name="element">The <see cref="FrameworkElement"/> for which to create a context menu.</param> /// <returns>The context menu that was created.</returns> protected override ContextMenu CreateContextMenu(FrameworkElement element) { var contextMenu = base.CreateContextMenu(element); if (contextMenu != null) { var button = element as RibbonControls.Primitives.ButtonBase; if ((button != null) && (contextMenu.Items.Count > 0)) { var menu = contextMenu.Items[0] as RibbonControls.Menu; if (menu != null) { MainControl.AddCustomMenuItem(button, menu); } } } return(contextMenu); }