# Ribbon Gallery

Telerik **RadRibbonView** provides a simple and consistent way for building interfaces similar to the ribbon control used in Microsoft Office. The **RadRibbonView** may consist of various elements, one of which is the **Ribbon Gallery**. This topic discusses concepts fundamental to the **Ribbon Gallery** at first and then goes into the usage of the **RadRibbonGallery** 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.

## Ribbon Gallery - Fundamentals

**Galleries** are simple, but a very powerful and flexible user interface concept. They are basically a scrollable list of items and the idea behind them is that each item shows the result of clicking it visually, rather than a static icon which points its purpose.

The gallery is always rendered in two ways:

* As a popup inside a **RadRibbonDropDownButton** or in **RadRibbonSplitButton**.

  ![WPF RadRibbonView Ribbon Gallery Popup](https://www.telerik.com/products/wpf/documentation/assets/038cf87c2c59c30d5693cdd0faa80634/ribbonview_gallery_popup.png)

* Directly into a [Ribbon Group](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-group).

  ![WPF RadRibbonView Ribbon Gallery in Group](https://www.telerik.com/products/wpf/documentation/assets/4035d59989efa22995d0fc45b707f75e/ribbonview_gallery_group.png)

> tip The classes that represent the ribbon gallery are **Telerik.Windows.Controls.RadRibbonGallery** and **Telerik.Windows.Controls.RadGallery**.

The **RadGallery** is a special type of **ListBox** (it derives from **ListBox**). The **RadGallery** class is used when you want to add a ribbon gallery as a popup. One important feature of the **RadGallery** is that it is **scrollable**. That's why you should always specify the [ViewportWidth](http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.viewportwidth.aspx) property. This controls the horizontal size of the content's viewport. On the other hand, the size of the items themselves is controlled by the **ItemWidth** and **ItemHeight** properties.

> tip When you want to declare a ribbon gallery inside a [RadRibbonDropDownButton](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/dropdown-button)/[RadRibbonSplitButton](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/split-button) use the **RadGallery** class.

> tip When you use the **RadGallery** class, you **should always specify** the **ViewportWidht** property.

The **RadRibbonGallery** is a special type of gallery (it derives from **RadGallery** class), that is designed to be hosted directly in a **RadRibbonControl**. Like the normal **RadGallery**, it has **Viewport Width\Height** and **Item Width\Height**. However, the viewport is constrained to the size of the ribbon itself.

> tip When you use the **RadRibbonGallery** class, **do not specify** the **ViewportWidth** property.

The **RadRibbonGallery** always should have a popup associated with it, otherwise the user won't be able to drop down the ribbon gallery. In the popup you may want to include a **RadMenu** that has other additional options regarding the gallery. However, when you drop down a **RadRibbonGallery** the items are automatically moved into the popup. So even if you specify a menu, the first item in the popup will be a gallery. On the other hand, while the items are hosted in the ribbon you can page up/down smoothly using the buttons inside the gallery.
![WPF RadRibbonView Gallery Buttons](https://www.telerik.com/products/wpf/documentation/assets/9f047b660178a35720fe822f6f1158f6/ribbonview_gallery_elements.png)

> tip When you want to declare a ribbon gallery directly into a [Ribbon Group](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-group) use the **RadRibbonGallery** class.

## Adding Ribbon Galleries to a RadRibbonView Control

Ribbon gallery can be always rendered in two ways - inside a [RadRibbonDropDownButton](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/dropdown-button)/[RadRibbonSplitButton](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/split-button) or directly into a [Ribbon Group](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-group).

### Adding Ribbon Gallery Inside a RadRibbonDropDownButton/RadRibbonSplitButton

When you want to declare a **Ribbon Gallery** as popup inside a [RadRibbonDropDownButton](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/dropdown-button)/[RadRibbonSplitButton](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/split-button), you should use the **RadGallery** class. The next example demonstrates how to do that.

```XAML
<telerik:RadRibbonView>
    <telerik:RadRibbonTab Header="Home">
        <telerik:RadRibbonGroup Header="Font" DialogLauncherVisibility="Visible">
            <StackPanel>
                <telerik:RadRibbonSplitButton SmallImage="Images/IconMSOffice/16/underline.png">
                    <telerik:RadRibbonSplitButton.DropDownContent>
                        <StackPanel>
                            <telerik:RadGallery ViewportWidth="157" ItemWidth="156"
	                                    ItemHeight="26">
                                <telerik:RadGalleryItem Image="Images/IconMSOffice/underline1.png"
	                                        ToolTipService.ToolTip="Underline" />
                                <telerik:RadGalleryItem Image="Images/IconMSOffice/underline2.png"
	                                        ToolTipService.ToolTip="Double underline" />
                                <telerik:RadGalleryItem Image="Images/IconMSOffice/underline3.png"
	                                        ToolTipService.ToolTip="Thick underline" />
                            </telerik:RadGallery>
                        </StackPanel>
                    </telerik:RadRibbonSplitButton.DropDownContent>
                </telerik:RadRibbonSplitButton>
            </StackPanel>
        </telerik:RadRibbonGroup>
    </telerik:RadRibbonTab>
</telerik:RadRibbonView>
```

Note that when you use the **RadGallery**, you should specify the **ViewportWidth** property. It controls the horizontal size of the content's viewport. On the other hand, the size of the items themselves is controlled by the **ItemWidth** and **ItemHeight** properties. The result from the example is shown on the next two snapshots.

![WPF RadRibbonView Gallery Split Button](https://www.telerik.com/products/wpf/documentation/assets/c787ce42f10c051002344518318df833/ribbonview_gallery_splitbtn.png)

When you press the popup launch button, the gallery is shown.

![WPF RadRibbonView Gallery Split Button Popup](https://www.telerik.com/products/wpf/documentation/assets/ba270f245725e9b5e0c1ac8aea1df5fc/ribbonview_gallery_splitbtn_popup.png)

### Adding Ribbon Gallery Directly Into a Ribbon Group

When you want to declare a **Ribbon Gallery** directly into a [Ribbon Group](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-group), you should use the **RadRibbonGallery** class. Consider again the previous example, add an additional **RadRibbonGroup** and declare a **RadRibbonGallery** like in the example below.

```XAML
<telerik:RadRibbonView>
    <telerik:RadRibbonTab Header="Home">
        <telerik:RadRibbonGroup Header="Font" DialogLauncherVisibility="Visible">
            <StackPanel>
                <telerik:RadRibbonSplitButton SmallImage="Images/IconMSOffice/16/underline.png">
                    <telerik:RadRibbonSplitButton.DropDownContent>
                        <StackPanel>
                            <telerik:RadGallery ViewportWidth="157" ItemWidth="156"
	                                    ItemHeight="26">
                                <telerik:RadGalleryItem
	                                        Image="Images/IconMSOffice/underline1.png"
	                                        ToolTipService.ToolTip="Underline" />
                                <telerik:RadGalleryItem
	                                        Image="Images/IconMSOffice/underline2.png"
	                                        ToolTipService.ToolTip="Double underline" />
                                <telerik:RadGalleryItem
	                                        Image="Images/IconMSOffice/underline3.png"
	                                        ToolTipService.ToolTip="Thick underline" />
                            </telerik:RadGallery>
                        </StackPanel>
                    </telerik:RadRibbonSplitButton.DropDownContent>
                </telerik:RadRibbonSplitButton>
            </StackPanel>
        </telerik:RadRibbonGroup>
        <telerik:RadRibbonGroup Header="Styles" DialogLauncherVisibility="Visible">
            <telerik:RadRibbonGallery Title="Quick Styles" ItemWidth="72" ItemHeight="56">
                <telerik:RadGalleryItem IsSelected="True"
	                        Image="Images/IconMSOffice/paragraph.png"
	                        ToolTipService.ToolTip="Normal" />
                <telerik:RadGalleryItem Image="Images/IconMSOffice/paragraph9.png"
	                        ToolTipService.ToolTip="No Spacing" />
                <telerik:RadGalleryItem Image="Images/IconMSOffice/paragraph8.png"
	                        ToolTipService.ToolTip="Heading 1" />
                <telerik:RadGalleryItem Image="Images/IconMSOffice/paragraph7.png"
	                        ToolTipService.ToolTip="Heading 2" />
                <telerik:RadGalleryItem Image="Images/IconMSOffice/paragraph6.png"
	                        ToolTipService.ToolTip="Title" />
                <telerik:RadGalleryItem Image="Images/IconMSOffice/paragraph5.png"
	                        ToolTipService.ToolTip="Subtitle" />
                <telerik:RadGalleryItem Image="Images/IconMSOffice/paragraph4.png"
	                        ToolTipService.ToolTip="Subtitle Emphasis" />
                <telerik:RadGalleryItem Image="Images/IconMSOffice/paragraph3.png"
	                        ToolTipService.ToolTip="Emphasis" />
                <telerik:RadGalleryItem Image="Images/IconMSOffice/paragraph2.png"
	                        ToolTipService.ToolTip="Intense Emphasis" />
                <telerik:RadGalleryItem Image="Images/IconMSOffice/paragraph1.png"
	                        ToolTipService.ToolTip="Strong" />
            </telerik:RadRibbonGallery>
        </telerik:RadRibbonGroup>
    </telerik:RadRibbonTab>
</telerik:RadRibbonView>
```

The result is shown on the image below.
![WPF RadRibbonView Ribbon Gallery](https://www.telerik.com/products/wpf/documentation/assets/1b115ef8c797426c45abbfb836f6ee09/ribbonview_gallery_ribbongallery.png)

When you press the popup launch button, the gallery is shown.
![WPF RadRibbonView Ribbon Gallery Popup](https://www.telerik.com/products/wpf/documentation/assets/18b6735cb43f0c3d57b4b8d0850b5ff7/ribbonview_gallery_ribbongallery_popup.png)

> tip While the items are hosted in the ribbon, you could **page up/down** smoothly using the buttons beside the gallery.

## Adding Additional Menu Items to a RadGallery

The **RadGallery** allows you to place in the popup additional menu options regarding the gallery. For that purpose you should use the **RadContextMenu** control.

The next code snippet demonstrates how to add additional menu items.

```XAML
<telerik:RadRibbonView>
    <telerik:RadRibbonTab Header="Home">
        <telerik:RadRibbonGroup Header="Font" DialogLauncherVisibility="Visible">
            <StackPanel>
                <telerik:RadRibbonSplitButton x:Name="UnderlineButton"
	                        SmallImage="Images/IconMSOffice/16/underline.png">
                    <telerik:RadRibbonSplitButton.DropDownContent>
                        <StackPanel>
                            <telerik:RadGallery ViewportWidth="157" ItemWidth="156"
	                                    ItemHeight="26">
                                <telerik:RadGalleryItem Image="Images/IconMSOffice/underline1.png"
	                                        ToolTipService.ToolTip="Underline" />
                                <telerik:RadGalleryItem Image="Images/IconMSOffice/underline2.png"
	                                        ToolTipService.ToolTip="Double underline" />
                                <telerik:RadGalleryItem Image="Images/IconMSOffice/underline3.png"
	                                        ToolTipService.ToolTip="Thick underline" />
                            </telerik:RadGallery>
                            <telerik:RadContextMenu BorderThickness="0">
                                <telerik:RadMenuItem Header="More underlines ..." />
                                <telerik:RadMenuItem Header="Underline color">
                                    <telerik:RadMenuItem.Icon>
                                        <Image Source="Images/IconMSOffice/colorpicker.png" />
                                    </telerik:RadMenuItem.Icon>
                                </telerik:RadMenuItem>
                            </telerik:RadContextMenu>
                        </StackPanel>
                    </telerik:RadRibbonSplitButton.DropDownContent>
                </telerik:RadRibbonSplitButton>
            </StackPanel>
        </telerik:RadRibbonGroup>
    </telerik:RadRibbonTab>
</telerik:RadRibbonView>
```

And the result is shown on the next image.
![WPF RadRibbonView Gallery Group Context Menu](https://www.telerik.com/products/wpf/documentation/assets/3816f8905ea90319d977025900066570/ribbonview_gallery_group_contextmenu.png)

## Adding Additional Menu Items to a RadRibbonGallery

You could also associate additional menu options with the **RadRibbonGallery** popup. In contrast to the **RadGallery** class, here the **RadRibbonGallery** exposes a special property for that purpose - **PopupMenuItems**.

In the next example several **RadMenuItem** objects are added to the **RadRibbonGallery**'s **PopupMenuItems** collection.

```XAML
<telerik:RadRibbonView>
    <telerik:RadRibbonTab Header="Home">
        <telerik:RadRibbonGroup Header="Styles" DialogLauncherVisibility="Visible">
            <telerik:RadRibbonGallery Title="Quick Styles" ItemWidth="72" ItemHeight="56">
                <telerik:RadRibbonGallery.PopupMenuItems>
                    <telerik:RadMenuItem Header="Save Selection as a Quick Style..." />
                    <telerik:RadMenuItem Header="Clear Formatting" />
                    <telerik:RadMenuItem Header="Apply Styles..." />
                </telerik:RadRibbonGallery.PopupMenuItems>
                <telerik:RadGalleryItem IsSelected="True" x:Name="Normal"
	                        Image="Images/IconMSOffice/paragraph.png" ToolTipService.ToolTip="Normal" />
                <telerik:RadGalleryItem Name="No_Spacing" Image="Images/IconMSOffice/paragraph9.png"
	                        ToolTipService.ToolTip="No Spacing" />
                <telerik:RadGalleryItem Name="Heading1" Image="Images/IconMSOffice/paragraph8.png"
	                        ToolTipService.ToolTip="Heading 1" />
                <telerik:RadGalleryItem Name="Heading2" Image="Images/IconMSOffice/paragraph7.png"
	                        ToolTipService.ToolTip="Heading 2" />
                <telerik:RadGalleryItem Name="Title" Image="Images/IconMSOffice/paragraph6.png"
	                        ToolTipService.ToolTip="Title" />
                <telerik:RadGalleryItem Name="Subtitle" Image="Images/IconMSOffice/paragraph5.png"
	                        ToolTipService.ToolTip="Subtitle" />
                <telerik:RadGalleryItem Name="Subtitle_Emphasis" Image="Images/IconMSOffice/paragraph4.png"
	                        ToolTipService.ToolTip="Subtitle Emphasis" />
                <telerik:RadGalleryItem Name="Emphasis" Image="Images/IconMSOffice/paragraph3.png"
	                        ToolTipService.ToolTip="Emphasis" />
                <telerik:RadGalleryItem Name="Intense_Emphasis" Image="Images/IconMSOffice/paragraph2.png"
	                        ToolTipService.ToolTip="Intense Emphasis" />
                <telerik:RadGalleryItem Name="Strong" Image="Images/IconMSOffice/paragraph1.png"
	                        ToolTipService.ToolTip="Strong" />
            </telerik:RadRibbonGallery>
        </telerik:RadRibbonGroup>
    </telerik:RadRibbonTab>
</telerik:RadRibbonView>
```

![WPF RadRibbonView Ribbon Gallery Context Menu](https://www.telerik.com/products/wpf/documentation/assets/fe6011adc41cb6c87430acf7417b4514/ribbonview_gallery_ribbongallery_contextmenu.png)

## Adding Header RadRibbonGalleryItems

You can visually group the **RadRibbonGallery** items when the gallery is in open state. You can do that by defining some of the **RadRibbonGalleryItems** as headers through the **IsHeader** bool property.

However, in order to properly display header items in the **RadRibbonGallery**, you need to change its default **ItemsPanel** to a **RibbonGalleryPanel**:

```XAML
<telerik:RadRibbonGallery>
    <telerik:RadRibbonGallery.ItemsPanel>
        <ItemsPanelTemplate>
            <ribbonViewPrimitives:RibbonGalleryPanel />
        </ItemsPanelTemplate>
    </telerik:RadRibbonGallery.ItemsPanel>
    <telerik:RadGalleryItem Content="Header1" IsHeader="True" />
    <telerik:RadGalleryItem Content="Item 1.1" />
    <telerik:RadGalleryItem Content="Item 1.2" />
    <telerik:RadGalleryItem Content="Item 1.3" />
    <telerik:RadGalleryItem Content="Header2" IsHeader="True" />
    <telerik:RadGalleryItem Content="Item 2.1" />
    <telerik:RadGalleryItem Content="Item 2.2" />
    <telerik:RadGalleryItem Content="Item 2.3" />
    <telerik:RadGalleryItem Content="Header3" IsHeader="True" />
    <telerik:RadGalleryItem Content="Item 3.1" />
    <telerik:RadGalleryItem Content="Item 3.2" />
</telerik:RadRibbonGallery>
```

![Rad Ribbon View Ribbon Gallery Headers](https://www.telerik.com/products/wpf/documentation/assets/96efc63e645d5c920d35253592db6967/radribbonview_ribbongallery_headers.png)

> The **telerikRibbonViewPrimitives** alias points to the **Telerik.Windows.Controls.RibbonView\.Primitives**
> `namespace:xmlns:telerikRibbonViewPrimitives="clr-namespace:Telerik.Windows.Controls.RibbonView.Primitives;assembly=Telerik.Windows.Controls.RibbonView"`

## Setting RadRibbonGallery's PopupLaunchButtonVisibility

The **RadRibbonGallery** class allows you to set the visibility of the launch popup button. The next example shows you how to set the **RadRibbonGallery**'s **PopupLaunchButtonVisibility** property to **Visibility.Collapsed**.

```XAML
<telerik:RadRibbonGallery Title="Quick Styles" ItemWidth="72" ItemHeight="56" PopupLaunchButtonVisibility="Collapsed">

</telerik:RadRibbonGallery>
```

![WPF RadRibbonView Ribbon Gallery Disabled Popup Button](https://www.telerik.com/products/wpf/documentation/assets/e28d19e074b42da481590598baf965bd/ribbonview_gallery_disable_popup.png)

## Setting RadRibbonGallery's LayoutMode

Since the **R2 2019** version, the RadRibbonGallery exposes a **LayoutMode** property, which is of type **RibbonLayout**. When this property is set to **Simplified**, the scroll buttons are collapsed and the RadRibbonGroup has a more streamlined look. This property is useful when the RadRibbonGroup is in the **SimplifiedItems** of a RadRibbonTab. For more information about it, check out the [Simplified Ribbon](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/simplified-ribbon) article.

## Working with Selection

The **RadGallery** derives directly from **ListBox**. So working with it is no different than using a standard **ListBox** control. Here are the related properties regarding the selection:

* **RadGallery.SelectedItem** - specifies the selected gallery item.

* **RadGallery.SelectedIndex** - specifies the selected index.

* **RadGalleryItem.IsSelected** - specifies whether the item is selected or not.

Also, to get notified about the change in the selection you can handle the **SelectionChanged** event.

## Events

The **RadGallery** class exposes two events - **ActivatePreview** and **DeactivatePreview**.

The **ActivatePreview** event is raised when the mouse cursor is over the gallery item. The **ActivatePreview** event handler receives two arguments:

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

The **DeactivatePreview** event is raised when the mouse cursor leaves the gallery item. The **DeactivatePreview** event handler receives two arguments:

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

> tip Since the **RadRibbonGallery** inherits the **RadGallery** class, you can handle the **ActivatePreview** and **DeactivatePreview** events in the **RadRibbonGallery** control as well.

```XAML
<telerik:RadRibbonGallery Title="Quick Styles" x:Name="QuickStyles" ItemWidth="72" ItemHeight="56" 
	                          ActivatePreview="QuickStyles_ActivatePreview" 
	                          DeactivatePreview="QuickStyles_DeactivatePreview">

</telerik:RadRibbonGallery>
```

```C#
private void QuickStyles_ActivatePreview(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    // Grab the RadRibbonGallery object
    RadRibbonGallery gallery = sender as RadRibbonGallery;
    // Get the selected item
    RadGalleryItem selectedItem = gallery.SelectedItem as RadGalleryItem;
}
private void QuickStyles_DeactivatePreview(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    // Grab the RadRibbonGallery object
    RadRibbonGallery gallery = sender as RadRibbonGallery;
    // Get the selected item
    RadGalleryItem selectedItem = gallery.SelectedItem as RadGalleryItem;
}
```

```VB.NET
	Private Sub QuickStyles_ActivatePreview(sender As Object, e As Telerik.Windows.RadRoutedEventArgs)
		' Grab the RadRibbonGallery object'
		Dim gallery As RadRibbonGallery = TryCast(sender, RadRibbonGallery)
		' Get the selected item'
		Dim selectedItem As RadGalleryItem = TryCast(gallery.SelectedItem, RadGalleryItem)
	
	End Sub
	
	Private Sub QuickStyles_DeactivatePreview(sender As Object, e As Telerik.Windows.RadRoutedEventArgs)
		' Grab the RadRibbonGallery object'
		Dim gallery As RadRibbonGallery = TryCast(sender, RadRibbonGallery)
		' Get the selected item'
		Dim selectedItem As RadGalleryItem = TryCast(gallery.SelectedItem, RadGalleryItem)
	End Sub
```

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 **ribbon galleries** are 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)
* [Quick Access ToolBar](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/qat)
* [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)
* [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)

## See Also

* [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)
* [Editing Control Templates](https://www.telerik.com/products/wpf/documentation/styling-and-appearance/styling-apperance-editing-control-templates)
