RadControls for WPF

Telerik RadRibbonBar provides a simple and consistent way for building interfaces similar to the RibbonBar used in Microsoft Office. The RadRibbonBar consists of various elements, one of which is the Quick Access Toolbar. This topic discusses concepts fundamental to the Quick Access Toolbar at first and then goes into the usage of the QuickAccessToolbar class and its features.

Tip
Before proceeding with this tutorial, it is recommended to get familiar with the Visual Structure of the RadRibbonBar control.

Quick Access ToolBar - Fundamentals

The Quick Access Toolbar is used to render a set of RadRibbon controls (commands) that are most commonly used in the application. It is rendered right next to the Application Menu button to make it easily accessible to end-users.

This is the default position of the QuickAccessToolbar. However, it is also possible to position the QuickAccessToolbar below the Ribbon control.

An integral part of the QuickAccessToolbar is the Quick Access Menu, which is rendered right next to the QuickAccessToolbar.

The QuickAccessMenu can be used by the end-user to choose the place of the QuickAccessToolbar - above or below the ribbon, or to hide the entire ribbon control.

Note

The class that represents the QuickAccessToolbar is Telerik.Windows.Controls.QuickAccessToolbar.

The QuickAccessToolbar control is an ItemsControl ( it indirectly derives from ItemsControl). That fact allows you to easily customize it by adding/removing commands.

Check out the rest of this topic, which is entirely dedicated to the QuickAccessToolbar.

Adding QuickAccessToolbar to a RadRibbonBar Control

In order to add a quick access toolbar to your RadRibbonBar control you need to set the RadRibbonBar's QuickAccessToolbar property. The next several code-snippets show you how to do that in XAML, as well as in the code-behind.

CopyXAML
<telerik:RadRibbonBar x:Name="radRibbonBar">
    <telerik:RadRibbonBar.QuickAccessToolBar>
        <telerik:QuickAccessToolBar />
    </telerik:RadRibbonBar.QuickAccessToolBar>
</telerik:RadRibbonBar>
CopyC#
this.radRibbonBar.QuickAccessToolBar = new QuickAccessToolBar();
CopyVB.NET
Me.radRibbonBar.QuickAccessToolBar = New QuickAccessToolBar()

Adding QuickAccessToolbar Items

When you want to add toolbar items to your RadRibbonBar's QuickAccessToolbar, you need to populate the QuickAccessToolbar's Items collection. It is handy to use the RadRibbonButton, RadRibbonSplitButton, RadRibbonDropDownButton and Separator controls.

Tip
For more information about the different types of RadRibbonButtons and their properties, take a look at the Ribbon Buttons topic.

The next example demonstrates how to add several buttons as toolbar items to your QuickAccessToolbar.

CopyXAML
<telerik:RadRibbonBar x:Name="radRibbonBar">
    <telerik:RadRibbonBar.QuickAccessToolBar>
        <telerik:QuickAccessToolBar>
            <telerik:RadRibbonButton Size="Small" 
                                     SmallImage="/RadRibbonBarSample;component/Images/IconMSOffice/16/save.png"
                                     Text="Save" />
            <telerik:RadRibbonButton Size="Small" 
                                     SmallImage="/RadRibbonBarSample;component/Images/IconMSOffice/16/undo.png"
                                     Text="Undo" />
            <telerik:RadRibbonButton Size="Small" 
                                     SmallImage="/RadRibbonBarSample;component/Images/IconMSOffice/16/print.png"
                                     Text="Print" />
        </telerik:QuickAccessToolBar>
    </telerik:RadRibbonBar.QuickAccessToolBar>
</telerik:RadRibbonBar>

The result can be seen on the snapshot below.

Changing the QuickAccessToolbar Position

The default position of the QuickAccessToolbar is right next to the ApplicationMenu button. However, you can change its position either in design-time or in run-time. In order to change the QuickAccessToolbar position desing-time, you need to set the RadRibbonBar's QuickAccessToolBarPosition property. Its values are predefined in the QuickAccessToolBarPosition enumeration, which exposes the following fields:

  • AboveRibbon - position the QuickAccessToolbar above the ribbon.
  • BelowRibbon - position the QuickAccessToolbar below the ribbon.
  • NotHosted - the QuickAccessToolbar is not hosted. Use this value, when you want to hide the QuickAccessToolbar.

The next example demonstrates how to set the QuickAccessToolBarPosition property.

CopyXAML
<telerik:RadRibbonBar x:Name="radRibbonBar" QuickAccessToolBarPosition="BelowRibbon" />
CopyC#
radRibbonBar.QuickAccessToolBarPosition = QuickAccessToolBarPosition.BelowRibbon;
CopyVB.NET
radRibbonBar.QuickAccessToolBarPosition = QuickAccessToolBarPosition.BelowRibbon

The result from the previous example is that when you run your application, the QuickAccessToolbar will be positioned below the ribbon.

Tip
The default value of the RadRibbonBar's QuickAccessToolBarPosition property is QuickAccessToolBarPosition.AboveRibbon.

RadRibbonBar has a built-in feature, which allows you to change the QuickAccessToolbar position run-time. Suffice it to execute the QuickAccessMenu's "Show below/above the Ribbon" command.

Hiding the QuickAccessToolbar

When you want to hide the QuickAccessToolbar, you should set the RadRibbonBar's QuickAccessToolBarPosition property to QuickAccessToolBarPosition.NotHosted.

CopyXAML
<telerik:RadRibbonBar x:Name="radRibbonBar" QuickAccessToolBarPosition="NotHosted" />
CopyC#
radRibbonBar.QuickAccessToolBarPosition = QuickAccessToolBarPosition.NotHosted;
CopyVB.NET
radRibbonBar.QuickAccessToolBarPosition = QuickAccessToolBarPosition.NotHosted

Events

The RadRibbonBar class exposes the ToolBarPositionChanged event, which is fired when the QuickAccessToolbar position is changed.

CopyXAML
<telerik:RadRibbonBar x:Name="radRibbonBar" ToolBarPositionChanged="radRibbonBar_ToolBarPositionChanged" />

The ToolBarPositionChanged event handler receives two arguments:

  • The sender argument contains the RadRibbonBar. This argument is of type object, but can be cast to the RadRibbonBar type.
  • The second argument is a RadRoutedEventArgs object.
CopyC#
private void radRibbonBar_ToolBarPositionChanged( object sender, RadRoutedEventArgs e )
{
    RadRibbonBar ribbonBar = sender as RadRibbonBar;
    QuickAccessToolBarPosition newPosition = ribbonBar.QuickAccessToolBarPosition;
    // Do some logic here.
}
CopyVB.NET
Private Sub radRibbonBar_ToolBarPositionChanged(ByVal sender As Object, ByVal e As RadRoutedEventArgs)
    Dim ribbonBar As RadRibbonBar = TryCast(sender, RadRibbonBar)
        ' Do some logic here.
    Dim newPosition As QuickAccessToolBarPosition = ribbonBar.QuickAccessToolBarPosition
End Sub
Tip
You can handle the ToolBarPositionChanged event to get notified when the user changes the ToolBar position.

For a full list of the exposed by the RadRibbonBar events, take a look at the Events - Overview topic.

The RadRibbonBar is a complex control and the QuickAccessToolbar is only a small part of it. The RadRibbonBar consists of various elements such as:

Additional features that you may find interesting are:

See Also