# Overview

There is a specific set of buttons introduced with the **RadRibbonView** control. They all inherit and extend the functionality of the standard button controls i.e. **RadRibbonToggleButton** derives from **RadToggleButton, RadRibbonSplitButton** derives from **RadSplitButton**, etc. The additional functionality which they provide allows you to easily implement MS-Office-Ribbon-like behavior in your application. This topic covers the common functionality for all ribbon buttons.

> The **RadRibbonButtons** can be used outside the **RadRibbonView** control as well.

The following Ribbon buttons are available:

* [Ribbon Button](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/ribbonbutton)
* [Ribbon ToggleButton](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/toggle-button)
* [Ribbon RadioButton](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/radio-button)
* [Ribbon DropDownButton](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/dropdown-button)
* [Ribbon SplitButton](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/split-button)

## Button States

There are three button states:

* **Large** - displays the large image and the text label defined for the button.

  ![WPF RadRibbonView Large Button State](https://www.telerik.com/products/wpf/documentation/assets/bc7993f31b30256f67ef159d0d6fa35e/ribbonview_buttons_overview_large.png)

* **Medium** - displays the small image and the text label defined for the button.

  ![WPF RadRibbonView Medium Button State](https://www.telerik.com/products/wpf/documentation/assets/7df3f74c685c88637179b5d04b5cd6c5/ribbonview_buttons_overview_medium.png)

* **Small** - displays the small image defined for the button.

  ![WPF RadRibbonView Small Button State](https://www.telerik.com/products/wpf/documentation/assets/cf7bed68f6a8f27ebbf4a32d9e0b472c/ribbonview_buttons_overview_small.png)

The state of the button depends on the state of the **RadRibbonGroup** and can be controlled via the **CollapseToSmall**, **CollapseToMedium** and the **IsAutoSize** properties of the ribbon buttons. To learn more about that take a look at the [Common Functionality](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-buttons/buttons-overview#Common-Functionality) section of this topic.

To learn more about the states of the **RadRibbonGroup** take a look at [this](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-group) topic.

## Common Functionality

As it was mentioned above all **RadRibbonButtons** derive from the base button controls. Each of them inherits the specifics of the respective button and implements additional functionality. Although they are different controls, there is a common set of properties explained below.

* **Text** - gets or sets the text label that is shown in **Medium** and **Large** button state.

* **SmallImage** - gets or sets the image that is shown in **Medium** and **Small** button state.

* **LargeImage** - gets or sets the image that is shown in **Large** button state.

* **Size** - gets or sets the button initial size. This will be the maximum size of the button as well.

* **SplitText** - enables or disables the text wrapping for the large-sized button. This property is available only for the **RadRibbonSplitButton, RadRibbonDropDownButton, RadRibbonButton**.

* **CollapseToSmall** - specifies when the button will be collapsed to its **Small** state, depending on the state of the **RadRibbonGroup** it belongs to.

* **CollapseToMedium** - specifies when the button will be collapsed to its **Medium** state, depending on the state of the **RadRibbonGroup** to which it belongs.

  > The **CollapseToSmall** and **CollapseToMedium** properties use the **CollapseThreshold** enumeration. It has the following values:
  >
  > * **Never** - indicates that the button will never collapse to **Small**/**Medium** state. This is the default value of the properties.
  > * **WhenGroupIsMedium** - indicates that the button will go to the **Small**/**Medium** state when its **RadRibbonGroup** is in **Medium** state.
  > * **WhenGroupIsSmall** - indicates that the button will go to the **Small**/**Medium** state when its **RadRibbonGroup** is in **Small** state.

* **IsAutoSize** -  specifies whether the button **Image** will be sized accordingly to the **RibbonView** guidance specification. If set to **False**, the button will display its images (both Small and Large) in its original size. Otherwise the **SmallImage** will be displayed with size of 16x16px and the **LargeImage** will be displayed with size of 32x32px.

* **TextRow1** -  gets the text that is shown in **Medium** and **Large** button state.

* **TextRow2** -  gets the text that is shown in the **Large** button state.

## Example

Here is an example of a **RadRibbonButton** with the following properties set.

```XAML
<telerik:RadRibbonButton CollapseToMedium="Never" 
	                         CollapseToSmall="WhenGroupIsMedium"
	                         IsAutoSize="True"
	                         LargeImage="Icons/32/Equation.png"
	                         Size="Large"
	                         SmallImage="Icons/16/Equation.png"
	                         Text="Equation" />
```

This button has its initial size set to **Large** and its text label set to **"Equation"**. As the **IsAutoSize** property is set to **True**, the button will change its size depending on the **RadRibbonGroup's** size. The button will also never collapse to its **Medium** size and will collapse to its Small size when the **RadRibbonGroup** collapses to **Medium**.
![WPF RadRibbonView Large Group Buttons](https://www.telerik.com/products/wpf/documentation/assets/f59fd723a9935a29dcbea60833162537/ribbonview_buttons_overview_largegroup.png)

and

![WPF RadRibbonView Small Group Buttons](https://www.telerik.com/products/wpf/documentation/assets/0075aee78bae1d83f2ab40cc510e4039/ribbonview_buttons_overview_collapsegroup.png)

## Handling the Button Clicks

There are two ways to implement a custom logic upon a button click - via event handler and via commands.

The first one is the standard way. You have to attach an event handler to the **Click** event of the button.

```XAML
<telerik:RadRibbonButton CollapseToMedium="Never" 
	                         
	                         Text="Equation" 
	                         Click="RadRibbonButton_Click"/>
```

```C#
private void RadRibbonButton_Click(object sender, RoutedEventArgs e)
{
    //place your custom logic here.
}
```

```VB.NET
	Private Sub RadRibbonButton_Click(sender As Object, e As RoutedEventArgs)
		'place your custom logic here.'
	End Sub
```

The other way is to set the **Command** property to a certain command. Here is an example of the command defined in the code-behind file of your UserControl. In order to create a command you have to create a static read-only instance of **System.Windows.Controls.RoutedUICommand** and then add execute and you can execute event handlers to the **System.Windows.Controls.CommandManager** class.

```C#
public partial class RibbonButtonsSample : UserControl
{
    public static readonly RoutedUICommand EquationCommand = new RoutedUICommand(
        "Equation",
        "EquationCommand",
        typeof(RibbonButtonsSample));
    public RibbonButtonsSample()
    {
        CommandManager.AddExecutedHandler(this, this.OnExecuted);
        CommandManager.AddCanExecuteHandler(this, this.OnCanExecute);
    }
    private void OnExecuted(object sender, ExecutedRoutedEventArgs e)
    {
        var LayoutRoot = (sender as RadRibbonButton).ParentOfType<Grid>();
        LayoutRoot.Background = new SolidColorBrush(Colors.Blue);
    }
    private void OnCanExecute(object sender, CanExecuteRoutedEventArgs e)
    {
        e.CanExecute = true;
    }
}
```

```VB.NET
	Public Partial Class RibbonButtonsSample
		Inherits UserControl
			Public Shared ReadOnly EquationCommand As New RoutedUICommand("Equation", "EquationCommand", GetType(RibbonButtonsSample))
	
			Public Sub New()
				InitializeComponent()
				CommandManager.AddExecutedHandler(Me, AddressOf Me.OnExecuted)
				CommandManager.AddCanExecuteHandler(Me, AddressOf Me.OnCanExecute)
			End Sub
			Private Sub OnExecuted(sender As Object, e As ExecutedRoutedEventArgs)
				Me.LayoutRoot.Background = New SolidColorBrush(Colors.Blue)
			End Sub
			Private Sub OnCanExecute(sender As Object, e As CanExecuteRoutedEventArgs)
				e.CanExecute = True
			End Sub
	
	End Class
```

After that set the **Command** property of the **RadRibbonButton** to the static command defined in code behind.

```XAML
<telerik:RadRibbonButton Text="Equation"
			Command="{x:Static local:RibbonButtonsSample.EquationCommand}" />
```

And now if you run your application and hit the 'Equation' button, the background of the user control will be changed to Blue as it is shown on the snapshot below.
![WPF RadRibbonView Change Background on Click of Button](https://www.telerik.com/products/wpf/documentation/assets/63a15364079659b27dd55ee8e751abca/ribbonview_buttons_overview_command.png)

## ButtonGroup

**RadRibbonView** allows you to additionally organize your buttons with common functionality (i.e. wrap Increase, Decrease Font buttons) in one panel. For this purpose you should use the **RadButtonGroup** class. It will automatically apply a  **Small Size** on all buttons wrapped in it. Furthermore, the **RadButtonGroup** is designed to create a separator between every two buttons in it.

> Because the RadRibbonGroup sets the Size of all child RadRibbonButtons to Small, the CollapseToSmall and CollapseToMedium properties of the button won't be respected.

The next example shows you how to use **RadButtonGroup**.

```XAML
<telerik:RadRibbonView x:Name="radRibbonView" Title="My Title" ApplicationName="My Application">
    <telerik:RadRibbonTab Header="Home">
        <telerik:RadRibbonGroup Header="Font">
            <telerik:RadOrderedWrapPanel>
                <telerik:RadButtonGroup>
                    <telerik:RadRibbonButton
	                            SmallImage="Images/IconMSOffice/16/font-increasesize.png" />
                    <telerik:RadRibbonButton
	                            SmallImage="Images/IconMSOffice/16/font-decreasesize.png" />
                </telerik:RadButtonGroup>
                <telerik:RadButtonGroup>
                    <telerik:RadRibbonButton
	                            SmallImage="Images/IconMSOffice/16/ClearFormatting16.png"
	                            Text="Clear Formatting" />
                </telerik:RadButtonGroup>
            </telerik:RadOrderedWrapPanel>
        </telerik:RadRibbonGroup>
    </telerik:RadRibbonTab>
</telerik:RadRibbonView>
```

![WPF RadRibbonView Button Group](https://www.telerik.com/products/wpf/documentation/assets/8292e4b367698dc43ae1e17c518b55c1/ribbonview_buttons_overview_buttongroup.png)

## See Also

* [Ribbon Group](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/ribbon-controls/ribbon-group)
* [Resizing](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/resizing)
* [Ordered Wrap Panel](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/layout-controls/ordered-wrap-panel)
* [Collapsible Panel](https://www.telerik.com/products/wpf/documentation/controls/radribbonview/features/layout-controls/collapsible-panel)
