Disabling "Add to Quick Access Toolbar" menu item

Ribbon for WPF Forum

Posted 13 years ago by AlexanderB - Software Developer, Edifecs
Version: 10.2.0531
Avatar
Hello

All my ribbon buttons are clonable (CloneService.CanCloneToQuickAccessToolBar for them is "True"). If I call Context menu for the button, it will contain "Add to Quick Access Toolbar" item. If I click this item - button will be cloned to QAT. If I call context menu for the same ribbon button later, "Add to Quick Access Toolbar" item will be grayed, so I cannot add the same button again.
So there is some CanExecute logic for command that clones controls to QAT, that checks if this control already in QAT or not. The question is: can I impact on this logic somehow?

I need to show "Add to Quick Access Toolbar" context menu item grayed in some cases, even when the control is not actually is in QAT yet (but some other controls are in QAT, that cannot be there with current control at the same time).

Thanks in advance

Comments (5)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Alexander,

You can temporarily set the CloneService.CanCloneToQuickAccessToolBar attached property to false to prevent a control from being cloned.

There is a RibbonCommands.AddToQuickAccessToolBar command in effect here. Ribbon has a CommandBinding to that command and the logic is as you saw, returns false if the control or a clone is on the QAT. Unfortunately there isn't a way to redefine that logic unless you alter the command binding to your own logic.


Actipro Software Support

Posted 13 years ago by AlexanderB - Software Developer, Edifecs
Avatar
Thanks for your answer, it was very helpful for me.

I reached needed behavior by handling CanExecutePreview event of RibbonCommands.AddTooQuickAccessToolBar command.
It works fine:
When user calls ribbon button's context menu, CanExecutePreview event of AddToQuickAccessToolBar is raised. I handle it and, according to my internal logic, set CanExecute to false if needed. In this case "Add to Quick Access Toolbar" item of context menu will be shown disabled (grey) - all as I want.

But there is another question:
When I open QAT customization popup menu, it shows items from QuickAccessToolBarCommonItems collection like checkboxes. If some of this items is already in QAT, it will be shown as checked. If no - unchecked.
By handing CanExecutePreview of AddToQuickAccessToolBar I can only impact on enabled/disabled state of these checkboxes (will it be drawn greyed or not).
Is there any way how I can imact on logic, that determines is such checkbox item should be checked or not.

Thanks
Posted 13 years ago by AlexanderB - Software Developer, Edifecs
Avatar
Thanks for your answer, it was very helpful for me.

I reached needed behavior by handling CanExecutePreview event of RibbonCommands.AddTooQuickAccessToolBar command.
It works fine:
When user calls ribbon button's context menu, CanExecutePreview event of AddToQuickAccessToolBar is raised. I handle it and, according to my internal logic, set CanExecute to false if needed. In this case "Add to Quick Access Toolbar" item of context menu will be shown disabled (grey) - all as I want.

But there is another question:
When I open QAT customization popup menu, it shows items from QuickAccessToolBarCommonItems collection like checkboxes. If some of this items is already in QAT, it will be shown as checked. If no - unchecked.
By handing CanExecutePreview of AddToQuickAccessToolBar I can only impact on enabled/disabled state of these checkboxes (will it be drawn greyed or not).
Is there any way how I can imact on logic, that determines is such checkbox item should be checked or not.

Thanks
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Alexander,

One of the criteria for matching items there is the attached RibbonControlService.Id property. So by changing that you could probably force an item unchecked. But there isn't a way to force it checked since we do additional checks to match ID and whether the item is a clone or not.


Actipro Software Support

Posted 13 years ago by AlexanderB - Software Developer, Edifecs
Avatar
Thanks for your help!
The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.