Next to the QuickAccessToolbar items there is a dropdown with "Show Below the Ribbon" and "Minimize the Ribbon" options. How do I get access to these elements so I can change the text. Wants to support multiple language in my application.
Regards,
Atle
7 Answers, 1 is accepted
Thank you for writing.
You could change the text of QuickAccessDropDown, but you should consider that it is dynamically generated when it is displayed for the first time. Moreover, the first part of the items depends of the buttons, which are added in QuickAccessToolbar so you should be careful about adding buttons at run-time.
Please review the code-block below:
private void Form1_Load(object sender, EventArgs e) |
{ |
RadToolStripOverFlowButtonElement quickAccessButton = ((RadToolStripOverFlowButtonElement)this.radRibbonBar1.RootElement.Children[0].Children[0].Children[0].Children[1].Children[1]); |
quickAccessButton.DropDownOpened += new EventHandler(quickAccessButton_DropDownOpened); |
} |
void quickAccessButton_DropDownOpened(object sender, EventArgs e) |
{ |
RenameQuickAccessDropDownItems(); |
} |
private void RenameQuickAccessDropDownItems() |
{ |
RadDropDownMenu quickAccessMenu = |
((RadToolStripOverFlowButtonElement)this.radRibbonBar1.RootElement.Children[0].Children[0].Children[0].Children[1].Children[1]).DropDownMenu; |
for (int i = 0; i < quickAccessMenu.Items.Count; i++) |
{ |
if (!(quickAccessMenu.Items[i] is RadMenuSeparatorItem)) |
{ |
quickAccessMenu.Items[i].Text = |
quickAccessMenu.Items[i].Text + String.Format(" (item{0})", i); |
} |
} |
} |
I hope this helps. Do not hesitate to contact me again if you need additional assistance.
Regards,
Martin Vasilev
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Can you please tell how can I add custom menu items in the dropdown of Quick AcCess Toolbar. The default items are "show bellow the ribbon" and "minimize the ribbon". I want to add one or two custom menus here through code.
The following article shows how you can add items programmatically: Customizing the Quick Access Menu.
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Telerik by Progress
The items are created dynamically so to add items just in the drop down you need to use the DropDownOpened event. For example:
public
RadForm1()
{
InitializeComponent();
radRibbonBar1.RibbonBarElement.QuickAccessToolBar.OverflowButtonElement.DropDownOpened += OverflowButtonElement_DropDownOpened;
}
private
void
OverflowButtonElement_DropDownOpened(
object
sender, EventArgs e)
{
var button = sender
as
RadQuickAccessOverflowButton;
button.Items.Add(
new
RadMenuItem(
"CustomItem"
));
}
Do not hesitate to contact us if you have other questions.
Dimitar
Telerik by Progress
Hi Dimitar,
Thank you for your help. I am facing a unique problem in this case. I am developing in C# WPF. I am using QuickAccessToolBar.RadRibbonDropDownButton item as I could not find QuickAccessToolBar.OverflowButtonElement and it is fine. If I use a simple RadRibbonView class for my Ribbon control and use DropDownOpened event as you suggested there is no problem. Everytime I click on the RadRibbonDropDownButton icon, the event is triggered and everything is perfect.
But the problem arises as I am using a class CustomRibbonView : RadRibbonView [CustomRibbonView is derived from RadRibbonView]. I HAVE NOT written any specific code for Quick Aceess Toolbar in this class [Am I missing a trick here?]. Now in the MainWindow.xaml.cs file in RibbonBar.Load event I have suscribed to DropDownOpened event. Please refer below:-
Now when the application is loaded for first time and I click on the RadRibbonDropDownButton icon in QAToolBar, ther suscribed event is fired and everything is fine. If I click on the first item i.e. "Show Below The Ribbon" and the toolbar goes below the ribbon as expected. But now if I click on the RadRibbonDropDownButton icon again, the event DropDownOpened is not fired and it is not fired anytime after.
Could not figure it out.
Please note that this is the WinForms forum. Please ask you questions about the WPF suite in the appropriate forum: UI for WPF Forums - Telerik Community.
Thank you for your understanding.
Regards,
Dimitar
Telerik by Progress