RadControls for WPF

The RadRibbonBar supports themes. This allows you to apply a style to all controls of the same type, without having to set it explicitly thus easily maintaining and changing the look of your RadRibbonBar.

Note

By applying a theme, the style for a particular control will be set to all of the controls of this type.

Creating the Theme

Before theming the RadRibbonBar controls, you have to create a Class Library project that will represent your theme. For example, create a project with the following name.

In the Generic.xaml you should place the styles and the resources for your theme.

Note

The RadRibbonBarTheme class should inherit from the Telerik.Windows.Controls.Theme class.

Adding Styles to the Theme

Copy the created style with all of the resources it uses and place it in the ResourceDictionary that represents the theme for your RadRibbonBar control. For example:

CopyXAML
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <!--Paste the style and all of the resources it uses here. --> 
    <Style x:Key="RadRibbonButtonStyle" TargetType="telerik:RadRibbonButton">
        ...
    </Style>
</ResourceDictionary>

The next step is to declare the required namespaces in the ResourceDictionary.

CopyXAML
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
      ...
</ResourceDictionary>

Finally in order to make the style default for all of the RadRibbonButton controls you have to set it to the following value.

CopyXAML
<Style x:Key="{telerik:ThemeResourceKey ThemeType={x:Type local:RadRibbonBarTheme}, ElementType={x:Type telerik:RadRibbonButton}}"
       TargetType="{x:Type telerik:RadRibbonButton}">
    ...
</Style>

Applying a Theme

The theme can be easily set to your RadRibbonBar control in the following way.

CopyXAML
<UserControl.Resources>
    <CustomThemes:RadRibbonBarTheme x:Key="MyTheme" />
<UserControl.Resources>
    ...
<telerik:RadRibbonBar x:Name="radRibbonBar"
                        telerik:StyleManager.Theme="{StaticResource MyTheme}">
CopyC#
public StylingPaneHeader()
{
    InitializeComponent();
    StyleManager.SetTheme( this.radRibbonBar, new RadRibbonBarTheme() );
}
CopyVB.NET
Public Sub New()
    InitializeComponent()
    StyleManager.SetTheme(Me.radRibbonBar, New RadRibbonBarTheme())
End Sub

See Also