Hello!
How can I dynamically customize RibbonView quick access toolbar? I want to show and hide buttons using quick access toolbar menu like in Microsoft Office applications. It seems that this is not possible and menu is not customizable either.
Thank you.
3 Answers, 1 is accepted
If I understood your requirement correctly, you wish to dynamically modify the collection of RadRibbonView's quick access toolbar. Please let me know if I'm mistaken in this assumption.
If that is indeed the desired result, you can bind the QuickAccessToolBar's ItemsSource to a collection in your viewmodel and define an ItemTemplate for its items. Provided this collection implements the INotifyCollectionChanged interface, it will update the toolbar once new items are added.
I've attached a small sample project to my reply demonstrating the approach I have in mind.
Could you please have a look and let me know if it will work for you? If this is not what you had in mind, please provide more details on your exact setup and requirement and I will gladly assist you further.
I look forward to your reply.
Regards,
Dilyan Traykov
Progress Telerik
Hello!
Thank you for your answer.
I want to customize the toolbar using it's menu. But the menu itself is not customizable. Can you please check how this menu looks like in the Microsoft Office application? It contains list of available buttons with checkmarks. User can show or hide any button on the toolbar using this menu.
How can I add custom items to the toolbar menu?
Thank you.
Please excuse me for the misunderstanding.
I've updated the project to demonstrate a possible approach for customizing the toolbar per your requirement. For the purpose I've modified the control template of the QuickAccessToolBar element and added an ItemsControl bound to the ItemsSource of the QuickAccessToolBar of the RadRibbonView. The ItemTemplate of the control in turn uses the properties of the data items to show and hide the items from the toolbar itself.
Please note that these changes are specific to the Office2016 theme and if you're using another one you should extract and modify the templates accordingly.
Please have a look and let me know whether this would work for you.
Regards,
Dilyan Traykov
Progress Telerik
Thank you for the sample, it works with version 2023 R2. But now your sample just shows the buttons with images. Nothing hapens when user clicks on any button inside the Quick Access ToolBar. How to add command to Click event?
Could you please extend your sample to add comands to the DataItems?
Thank you!
I already posted a reply in the ticket related to this thread (1618797). I am attaching the modified version of Dilyan's project where no ControlTemplate modifications are requirement also here.
As for Dilyan's example, you can add actions by adding a new property of type ICommand in the DataItem class from the project. Then, you can data bind this property in the RadRibbonButton defined in the ItemTemplate.
<DataTemplate x:Key="Template">
<telerik:RadRibbonButton Text="{Binding Header}"
Command="{Binding MyCommand}"
Visibility="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
Size="Small" SmallImage="{Binding ImageUrl}"
telerik:KeyTipService.AccessText="{Binding AccessText}" />
</DataTemplate>
For each DataItem you can define a different ICommand isntance. I hope that helps.