private static void AddToQATCanExecute(object sender, CanExecuteRoutedEventArgs args) { DependencyObject thatCanBeAddedToQat = MyRibbon.FindElementThatCanBeAddedToQAT(args.OriginalSource as DependencyObject); if (thatCanBeAddedToQat == null || RibbonControlService.GetQuickAccessToolBarId(thatCanBeAddedToQat) == null || RibbonHelper.ExistsInQAT(thatCanBeAddedToQat)) { return; } args.CanExecute = true; }
private static void AddToQATExecuted(object sender, ExecutedRoutedEventArgs args) { var ribbon0 = (MyRibbon)sender; object model = AttachedProperties.GetModel(ribbon0); if ((model is PrimaryRibbonModel primary)) { if (!(MyRibbon.FindElementThatCanBeAddedToQAT((DependencyObject)(args.OriginalSource as UIElement)) is UIElement thatCanBeAddedToQat)) { return; } RibbonQuickAccessToolBarCloneEventArgs barCloneEventArgs = new RibbonQuickAccessToolBarCloneEventArgs(thatCanBeAddedToQat); thatCanBeAddedToQat.RaiseEvent((RoutedEventArgs)barCloneEventArgs); MyRibbon ribbon = RibbonControlService.GetRibbon((DependencyObject)thatCanBeAddedToQat) as MyRibbon; if (barCloneEventArgs.CloneInstance == null) { return; } primary.QuickAccessToolBar.Items.Add((object)barCloneEventArgs.CloneInstance); args.Handled = true; } }