# Quick Access Toolbar

Telerik **RadRibbonView** provides a simple and consistent way for building interfaces similar to the RibbonView used in Microsoft Office. The **RadRibbonView** 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](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/general-information/visual-structure) of the **RadRibbonView** control.

## Quick Access ToolBar - Fundamentals

The **Quick Access Toolbar** is used to render a set of **RadRibbonView** controls that are most commonly used in the application. It is rendered above  the **ApplicationButton** to make it easily accessible to end-users.

![WPF RadRibbonView Quick Access ToolBar Overview](https://www.telerik.com/products/wpf/documentation/assets/5161ebaa392ac80d5696b063c3aafb9b/ribbonview_qat_overview.png)

This is the **default** position of the **Quick Access Toolbar**. However, it is also possible to position the Quick Access Toolbar **below** the Ribbon control.

![WPF RadRibbonView Quick Access ToolBar Bottom](https://www.telerik.com/products/wpf/documentation/assets/809d2fb48e0ed6377dc4bcd099e77292/ribbonview_qat_bellow.png)

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

![WPF RadRibbonView Quick Access Menu](https://www.telerik.com/products/wpf/documentation/assets/f58573dbec361621c9cf3b47d3bf00a6/ribbonview_qat_menu.png)

The Quick Access Menu can be used by the end-user to choose the place of the Quick Access Toolbar - **above** or **below** the ribbon, or to **hide** the entire ribbon control.

> The class that represents the Quick Access Toolbar is **Telerik.Windows.Controls.QuickAccessToolbar**.

The **QuickAccessToolbar** control is an [ItemsControl](http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.aspx) ( 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 RadRibbonView Control

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

```XAML
<telerik:RadRibbonView x:Name="radRibbonView" Title="My Title" ApplicationName="My Application">
    <telerik:RadRibbonView.QuickAccessToolBar>
        <telerik:QuickAccessToolBar />
    </telerik:RadRibbonView.QuickAccessToolBar>
</telerik:RadRibbonView>
```

```C#
this.radRibbonView.QuickAccessToolBar = new QuickAccessToolBar();
```

```VB.NET
	Me.radRibbonView.QuickAccessToolBar = New QuickAccessToolBar()
```

## Adding QuickAccessToolbar Items

When you want to add toolbar items to your **RadRibbonView**'s Quick Access Toolbar, you need to populate the **QuickAccessToolbar**'s **Items** collection. It is handy to use the **RadRibbonButton**, **RadRibbonSplitButton**, **RadRibbonDropDownButton** and **RadToolBarSeparator** controls.

> tip For more information about the different types of **RadRibbonButtons** and their properties, take a look at the [Ribbon Buttons](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/buttons-overview) topic.

The next example demonstrates how to add several buttons as toolbar items to your Quick Access Toolbar.

```XAML
<telerik:RadRibbonView>
    <telerik:RadRibbonView.QuickAccessToolBar>
        <telerik:QuickAccessToolBar>
            <telerik:RadRibbonButton Text="Save" SmallImage="Images/IconMSOffice/16/save.png"
	                                        Size="Small"
	                                        telerik:KeyTipService.AccessText="1" />
            <telerik:RadRibbonButton Text="Undo" SmallImage="Images/IconMSOffice/16/undo.png"
	                                        Size="Small"
	                                        telerik:KeyTipService.AccessText="2" />
            <telerik:RadRibbonButton Text="Print" SmallImage="Images/IconMSOffice/16/print.png"
	                                        Size="Small"
	                                        telerik:KeyTipService.AccessText="3" />
        </telerik:QuickAccessToolBar>
    </telerik:RadRibbonView.QuickAccessToolBar>
</telerik:RadRibbonView>
```

The result can be seen on the snapshot below.
![WPF RadRibbonView Quick Access ToolBar Buttons](https://www.telerik.com/products/wpf/documentation/assets/bc135409680079bdeecc19f6e790e125/ribbonview_qat_sample.png)

## Changing the QuickAccessToolbar Position

The default position of the **QuickAccessToolbar** is right next to the [Application Menu](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/applicationmenu) button. However, you can change its position either design-time or run-time. In order to change the **QuickAccessToolbar** position design-time, you need to set the **RadRibbonView**'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.

```XAML
<telerik:RadRibbonView  QuickAccessToolBarPosition="BelowRibbon"/>
```

```C#
radRibbonView.QuickAccessToolBarPosition = QuickAccessToolBarPosition.BelowRibbon;
```

```VB.NET
	radRibbonView.QuickAccessToolBarPosition = QuickAccessToolBarPosition.BelowRibbon
```

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

![WPF RadRibbonView Quick Access ToolBar Below Ribbon](https://www.telerik.com/products/wpf/documentation/assets/4fafff88a931a0fc7d8174bbd59f3dbd/ribbonview_qat_bellowsample.png)

> tip The default value of the **RadRibbonView**'s **QuickAccessToolBarPosition** property is **QuickAccessToolBarPosition.AboveRibbon**.

**RadRibbonView** 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.

![WPF RadRibbonView Quick Access ToolBar Show Bellow Ribbon Button](https://www.telerik.com/products/wpf/documentation/assets/103c5281613549131d48e669cdf95584/ribbonview_qat_showbellow.png)

## Hiding the QuickAccessToolbar

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

```XAML
<telerik:RadRibbonView  QuickAccessToolBarPosition="NotHosted"/>
```

```C#
radRibbonView.QuickAccessToolBarPosition = QuickAccessToolBarPosition.NotHosted;
```

```VB.NET
	radRibbonView.QuickAccessToolBarPosition = QuickAccessToolBarPosition.NotHosted
```

## Styling QuickAccessToolbar items using ItemContainerStyleSelector

The `QuickAccessToolbar` provides predefined styles for its items. Use its `ItemContainerStyleSelector` property to select a style for each item.

First, define a `RadRibbonView` with a `QuickAccessToolbar`:

```XAML
<telerik:RadRibbonView ApplicationButtonContent="File">
    <telerik:RadRibbonView.QuickAccessToolBar>
        <telerik:QuickAccessToolBar>
            <telerik:RadRibbonButton Text="Save" Foreground="White" />
            <telerik:RadRibbonButton Text="Print" Foreground="White"/>
        </telerik:QuickAccessToolBar>
    </telerik:RadRibbonView.QuickAccessToolBar>
</telerik:RadRibbonView>
```

Create a custom `StyleSelector` that selects a style for each `RadRibbonButton` based on its text:

```C#
public class QATItemContainerStyleSelector : StyleSelector
{
    public Style SaveStyle { get; set; }
    public Style PrintStyle { get; set; }

    public override Style SelectStyle(object item, DependencyObject container)
    {
        var button = item as RadRibbonButton;
        if (button != null)
        {
            if (button.Text == "Save")
            {
                return this.SaveStyle;
            }
            else if (button.Text == "Print")
            {
                return this.PrintStyle;
            }
        }

        return base.SelectStyle(item, container);
    }
}
```

```VB.NET
Public Class QATItemContainerStyleSelector
    Inherits StyleSelector
    Public Property SaveStyle() As Style
        Get
            Return m_SaveStyle
        End Get
        Set
            m_SaveStyle = Value
        End Set
    End Property
    Private m_SaveStyle As Style
    Public Property PrintStyle() As Style
        Get
            Return m_PrintStyle
        End Get
        Set
            m_PrintStyle = Value
        End Set
    End Property
    Private m_PrintStyle As Style

    Public Overrides Function SelectStyle(item As Object, container As DependencyObject) As Style
        Dim button = TryCast(item, RadRibbonButton)
        If button IsNot Nothing Then
            If button.Text = "Save" Then
                Return Me.SaveStyle
            ElseIf button.Text = "Print" Then
                Return Me.PrintStyle
            End If
        End If

        Return MyBase.SelectStyle(item, container)
    End Function
End Class
```

Define the two custom styles and assign the `QATItemContainerStyleSelector` to the toolbar's `ItemContainerStyleSelector` property:

```XAML
<Style x:Key="PrintStyle" TargetType="telerik:RadRibbonButton" BasedOn="{StaticResource RadRibbonButtonStyle}">
    <Setter Property="Background" Value="Red" />
    <Setter Property="Size" Value="Medium" />
</Style>

<Style x:Key="SaveStyle" TargetType="telerik:RadRibbonButton" BasedOn="{StaticResource RadRibbonButtonStyle}">
    <Setter Property="Background" Value="Blue" />
    <Setter Property="Size" Value="Medium" />
</Style>

<local:QATItemContainerStyleSelector x:Key="QATItemContainerStyleSelector"
            PrintStyle="{StaticResource PrintStyle}"
            SaveStyle="{StaticResource SaveStyle}" />

<Style BasedOn="{StaticResource QuickAccessToolBarStyle}" TargetType="telerik:QuickAccessToolBar">
    <Setter Property="ItemContainerStyleSelector" Value="{StaticResource QATItemContainerStyleSelector}" />
</Style>
```

This example uses [NoXaml assemblies](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-setting-a-theme-overview). Its styles are based on the [default styles](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-styling-the-controls) for the theme.

> caption QuickAccessToolbar items styled with an ItemContainerStyleSelector

![QuickAccessToolbar with styled items](https://www.telerik.com/products/wpf/documentation/assets/ed5a3279292d1c24aec1eb702e22f0a5/radribbonview_quickaccesstoolbar_itemcontainerstyleselector.png)

## Events

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

```XAML
<telerik:RadRibbonView ToolBarPositionChanged="radRibbonView_ToolBarPositionChanged"/>
```

The **ToolBarPositionChanged** event handler receives two arguments:

* The sender argument contains the **RadRibbonView**. This argument is of type **object**, but can be cast to the **RadRibbonView** type.
* The second argument is a **RadRoutedEventArgs** object.

```C#
private void radRibbonView_ToolBarPositionChanged(object sender, RadRoutedEventArgs e)
{
    RadRibbonView ribbonView = sender as RadRibbonView;
    QuickAccessToolBarPosition newPosition = ribbonView.QuickAccessToolBarPosition;
    // Do some logic here.
}
```

```VB.NET
	Private Sub radRibbonView_ToolBarPositionChanged(ByVal sender As Object, ByVal e As RadRoutedEventArgs)
	Dim ribbonView As RadRibbonView = TryCast(sender, RadRibbonView)
	' Do some logic here.'
	Dim newPosition As QuickAccessToolBarPosition = ribbonView.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 **RadRibbonView** events, take a look at the [Events - Overview](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/events/overview) topic.

The **RadRibbonView** is a complex control and the **Quick Access Toolbar** is only a small part of it. The **RadRibbonView** consists of various elements such as:

* [Application Menu](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/applicationmenu)
* [Backstage Menu](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-backstage)
* [Ribbon Tab](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-tab)
* [Ribbon Group](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-group)
* [Ribbon Gallery](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-gallery)
* [RibbonButtons Overview](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/buttons-overview)
* [Ribbon ComboBox](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-combobox)
* [Screen Tips](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/screentips)

Additional features that you may find interesting are:

* [Selection](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/selection)
* [Resizing](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/resizing)
* [Minimization](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/minimization)
* [Localization](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/localization)

## See Also

* [Editing Control Templates](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-editing-control-templates)
