Click here to Skip to main content
15,612,594 members
Articles / Web Development
Posted 11 Jan 2011


43 bookmarked

A Quick Guide to Silverlight Ribbon Controls (Part - 1)

Rate me:
Please Sign up or sign in to vote.
4.88/5 (24 votes)
11 Jan 2011CPOL8 min read
A Quick Guide to Silverlight Ribbon Controls (Part - 1)


Microsoft Office 2010 has a cool new Ribbon Control bar which looks pretty rich and it is very easy to use compared to the old Menu bar. Probably you may know that we can create such Ribbon bar using WPF but did anyone think about whether we can do it using Silverlight too, very easily?

DotNetBar Ribbon Silverlight Control with Office styling

Yes, we can create such Ribbon UI for our Silverlight application. So, if you want it for your Silverlight application, you can implement it very easily after reading these series of articles on Ribbon control.

Introduction to Silverlight Ribbon Control

Devcomponent has their own component called DotNetBar for Silverlight. It includes some good controls like Ribbon bar, Scheduler, Navigation Pane, etc. Among them, I started with exploring the features of the Silverlight Ribbon Control. It looks pretty cool to me. Thought of sharing my exploration of this with you.

The DotNetBar includes Office 2010 style Ribbon control with blue, silver, black and custom color scheme blending based on single color. It supports MVVM as well as 100% code based control creation and setup. You can download the trial version of the library from DevComponents site. Here is the link of the download page: DotNetBar for Silverlight.

Features of Silverlight Ribbon Control

  • Microsoft Office 2010 style look and feel.
  • Three different varieties of color scheme included like: Blue, Black, Silver color.
  • You can customize the color scheme generation based on a single color too.
  • A full set of controls are included to use with Ribbon Control:
    • Button
    • ToggleButton
    • RadioButton
    • DropDownButton
    • SplitButton
    • ComboBox
    • MenuItem
    • Gallery
    • InRibbonGallery
    • LayoutControl
  • Supports automatic Ribbon sizing.
  • Normal, Minimized, Collapsed and open in Popup views are supported like Office 2010.
  • Office 2010 Style Backstage Application Menu.
  • Quick Access Toolbar support.
  • Customizable context menu support.
  • Advanced Tooltips support.
  • Reusable resources so you can reuse some predefined brushes.
  • Automatic resizing of Ribbon toolbar.
  • Command preview for Galleries are also available.
  • Complete re-style, re-template supported by this library.
  • MVVM architecture support.

Know More on Ribbon Control

DevComponents.Silverlight.Ribbon.Ribbon is the top level container for all that makes up a Ribbon UI. Ribbon inherits from ItemsHostControl and is meant to contain a collection of RibbonTabItem. You can place any UI Element inside the Ribbon but it will not render once the application loads.

Ribbon’s SystemToolbarItems is an ObservableCollection of UIElements. All items in the collection are rendered on the far right of the Ribbon, at the same vertical level as the ribbon tab items. By default, this collection is empty.

The QuickAccessToolbarItems is also an ObservableCollection of UIElements. All items placed in this collection are rendered on the top left corner of the Ribbon control’s boundaries.

Ribbon.BackstageContent is used to set the object which is displayed in the Popup when the Backstage (or File) toggle button is checked. By default, this property is null. To get or set whether the backstage is open, use the IsBackStageOpen property.

By default, the Backstage button displays the text "File". This can be changed via the BackstageButtonContent property. To hide the backstage button altogether, set BackstageButtonVisibility = false.

The Ribbon always displays the content provided by the currently selected item. Get or set the currently selected item via the SelectedItem dependency property.

The ribbon can be minimized by setting the IsMinimized property to true. When minimized, the tab items are visible but the content is hidden. When minimized, the content can be shown in a popup by setting IsPopupOpen to true. If a user clicks on a tab when the Ribbon is minimized, the tab item will be selected and the popup will open to show the content. By default, the user can toggle between minimized and normal state by double clicking on a tab item. This can be overridden by setting DoubleClickTabToggleEnabled = false.

The ribbon can be collapsed by setting IsCollapsed = true. When collapsed, no portion of the Ribbon is visible. By default, the ribbon collapses automatically when either its width or the height of the hosting Silverlight application reaches certain minimum values. These values are defined in RibbonResources as RibbonCollapseWidth and RibbonCollapseApplicationHeight, respectively.

Preparing the Project

Once you downloaded the DotNetBar Library for Silverlight, install them in your local PC. It has some cool samples. Before going through them, let us start creating our own sample project step-by-step and explore it to learn.

Create a Silverlight application project. Once created, add two DLL assembly reference named "DevComponents.Silverlight.Controls.dll" and "DevComponents.Silverlight.Ribbon.dll" to your project from the installation directory.


Generally, you will find them under "Program Files\DotNetBarSilverlight" directory. These two assemblies are required for you to start working with it.


Once you added the reference, I will suggest you restructure your project in MVVM pattern. In this article, we will not use the MVVM, but in future articles it will be helpful for you. Create "Models", "Views", "ViewModels" and "Images" directory inside your solution root. Also, create the MainView.xaml and MainViewModel.cs files under the appropriate directories. Build your solution and you will encounter some build errors. Fix them to start with the next steps.


Inherit your MainViewModel from the ViewModelBase, which is part of the namespace called "DevComponents.Silverlight.Controls.ViewModel". Include the namespace as shown above. Now, your solution is ready for our next steps.

Adding a Ribbon Control

Once your dev environment is ready including the project, we can jump into the XAML code to create a cool looking Ribbon bar control for our Silverlight application. Open your MainView.xaml page and add the XMLNS namespace "DevComponents.Silverlight.Ribbon" in the same XAML page.

Have a look into the following screenshot for reference:


Split your main "LayoutRoot" grid into two rows. In the first row, we will place the ribbon bar. We will use the second row later if required.

Here is the XAML code for your reference:

<UserControl x:Class="DevComponentRibbonDemo.Views.MainView"
    <Grid x:Name="LayoutRoot" Background="White">
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>

Now, add the following XAML code inside your LayoutRoot:

<r:Ribbon x:Name="ribbon" 
          IsMinimized="False" IsCollapsed="False"
          BackstageButtonVisibility="Visible" BackstageColor="Blue">

This will add the Ribbon bar control in your page. Build and run your application. You will see the below naked Ribbon bar at the top of your application:


Adding Ribbon Tab Items

DevComponents.Silverlight.Ribbon.RibbonTabItem is the second level container for all that makes up a Ribbon UI. This is the main content control for the Ribbon.

The Label property sets the string value which is displayed by the tab item.

Use IsSelected to get or set whether the tab item is selected. Setting this property to true will change the value of Ribbon.SelectedItem.

RibbonBarResizeOrder is used to create a stack of references to RibbonBars, defining the order in which they are shrunk as the Ribbon is made smaller or fully expanded.

Now it's time for us to add some Ribbon items in the bar. Use RibbonTabItem inside the Ribbon control to add some child elements. Use the property "Label" to specify the label for each tab item. Have a look into the following code snippet:

<r:Ribbon x:Name="ribbon" 
          IsMinimized="False" IsCollapsed="False"
          BackstageButtonVisibility="Visible" BackstageColor="Blue">
    <r:RibbonTabItem Label="Edit"></r:RibbonTabItem>
    <r:RibbonTabItem Label="View"></r:RibbonTabItem>
    <r:RibbonTabItem Label="Project"></r:RibbonTabItem>
    <r:RibbonTabItem Label="Build"></r:RibbonTabItem>

Here, we added four different RibbonTabItems named "Edit", "View", "Project" and "Build". If you run your application now, you will see the below UI inside the browser window:


Chose the various tab items and you will notice that, every tab controls are totally blank. But you are able to switch between each tabs as you do in Office 2010.


Once it is ready, why not to add some controls inside one of the tab control? Let's start doing it. Inside one of the tab item, add a RibbonBar item and put some buttons there.

Adding Ribbon Control Items

Ribbon Tab Item can contain any items. If you want a auto resized panel, use one more RibbonBar inside it. Another way to do is the use of LayoutControl. A LayoutControl is a kind of like a multi-line toolbar which supports multiple layout definitions. Layout definitions allow you to specify exactly where each control is rendered in relationship to the other controls. A layout control may have multiple layout definitions, each of a different width. As the Ribbon is resized, the most appropriate layout definition is used according to the available space.

The Label property sets the string value which is displayed by the ribbon bar along its bottom edge.

Let us create an UI like this, where we will have a medium sized paste button and two small sized Cut and Copy buttons:


We will put them inside the Edit tab item. For this layout type, we don't need a multiple line layout. So, we can use the auto resized panel, i.e., one more RibbonBar inside it. Hence, expand the control and add a Split button for giving the user a paste button. Also add two normal ribbon buttons for the cut and copy looks.

Find the exact code of the same here:

<r:RibbonTabItem Label="Edit">
  <r:RibbonBar Label="Clipboard">
      <r:SplitButton x:Name="PasteSplitButton" Label="Paste" 
			"Paste the copied content from the Clipboard."
                     r:Ribbon.ToolTipHeader="Paste (Ctrl + V)" />
      <r:Button x:Name="CutButton" Label="Cut" 
                r:Ribbon.ToolTipContent="Cut the selection and put it in the Clipboard." 
                r:Ribbon.ToolTipHeader="Cut (Ctrl + X)" />
      <r:Button x:Name="CopyButton" Label="Copy"
                r:Ribbon.ToolTipContent="Copy the selection and put it in the Clipboard." 
                r:Ribbon.ToolTipHeader="Paste (Ctrl + V)"/>

You can notice that, each buttons are from the ribbon library and those have different sets of properties to show the tooltip, image, label etc.

Now run your application. You will see the ribbon control having the three buttons called Cut, Copy and Paste into the screen. BTW, those buttons are not functional as we didn't implement their features.


Hover your mouse on top of each control and you will see a great tooltip like the Office 2010 window. Have a look into the below screenshot:


You can also customize the tooltip to show more complex elements inside it. We will discuss it later.

End Note

Hope you enjoyed reading this first part of the Ribbon Controls for Silverlight. This is just a beginner series to start working with the same. Many more yet to come. In the 2nd part, we will discuss more on the Layout and controls.

The sample has been created using the Licensed version of DotNetBar. If you download the source code and run without license, may get "Invalid License Key" warning in the UI.

Don't forget to vote and share your feedback about the article. This will help me to provide you with a much better article in the future.

You can get the source code of this sample from here (external source):



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Lead
India India

Kunal Chowdhury is a former Microsoft "Windows Platform Development" MVP (Most Valuable Professional, 2010 - 2018), a Codeproject Mentor, Speaker in various Microsoft events, Author, passionate Blogger and a Senior Technical Lead by profession.

He is currently working in an MNC located in India. He has a very good skill over XAML, C#, Silverlight, Windows Phone, WPF and Windows app development. He posts his findings, articles, tutorials in his technical blog ( and CodeProject.

Books authored:

Connect with Kunal on:

Comments and Discussions

GeneralMy vote of 3 Pin
Kam10-Nov-11 6:47
Kam10-Nov-11 6:47 
GeneralMy vote of 2 Pin
toantvo7-Sep-11 18:08
toantvo7-Sep-11 18:08 
QuestionNo 'DevComponents' DLL found Pin
Hloni Matsoso4-Jul-11 18:43
Hloni Matsoso4-Jul-11 18:43 
AnswerRe: No 'DevComponents' DLL found Pin
Kunal Chowdhury «IN»4-Jul-11 19:16
professionalKunal Chowdhury «IN»4-Jul-11 19:16 
GeneralMy vote of 5 Pin
ZeeroC00l12-May-11 22:40
ZeeroC00l12-May-11 22:40 
General5 From Me Pin
Gandalf_TheWhite17-Jan-11 23:01
professionalGandalf_TheWhite17-Jan-11 23:01 
GeneralMy vote of 5 Pin
Slacker00712-Jan-11 4:26
professionalSlacker00712-Jan-11 4:26 
GeneralRe: My vote of 5 Pin
Kunal Chowdhury «IN»12-Jan-11 4:31
professionalKunal Chowdhury «IN»12-Jan-11 4:31 
General[My vote of 1] Really nice written(so why do i down voted) Pin
Selvin12-Jan-11 4:25
Selvin12-Jan-11 4:25 
GeneralRe: [My vote of 1] Really nice written(so why do i down voted) Pin
Slacker00712-Jan-11 4:28
professionalSlacker00712-Jan-11 4:28 
GeneralRe: [My vote of 1] Really nice written(so why do i down voted) Pin
Kunal Chowdhury «IN»12-Jan-11 4:46
professionalKunal Chowdhury «IN»12-Jan-11 4:46 
GeneralRe: [My vote of 1] Really nice written(so why do i down voted) Pin
Selvin12-Jan-11 4:55
Selvin12-Jan-11 4:55 
AnswerRe: [My vote of 1] Really nice written(so why do i down voted) Pin
Kunal Chowdhury «IN»12-Jan-11 5:03
professionalKunal Chowdhury «IN»12-Jan-11 5:03 
GeneralRe: [My vote of 1] Really nice written(so why do i down voted) Pin
Slacker00712-Jan-11 5:04
professionalSlacker00712-Jan-11 5:04 
AnswerRe: [My vote of 1] Really nice written(so why do i down voted) Pin
Kunal Chowdhury «IN»12-Jan-11 4:42
professionalKunal Chowdhury «IN»12-Jan-11 4:42 
GeneralMy vote of 5 Pin
Durgaprasad Budhwani12-Jan-11 1:31
Durgaprasad Budhwani12-Jan-11 1:31 
GeneralRe: My vote of 5 Pin
Kunal Chowdhury «IN»12-Jan-11 1:58
professionalKunal Chowdhury «IN»12-Jan-11 1:58 
GeneralMy vote of 5 Pin
Abhishek Sur11-Jan-11 22:11
professionalAbhishek Sur11-Jan-11 22:11 
GeneralRe: My vote of 5 Pin
Kunal Chowdhury «IN»11-Jan-11 22:15
professionalKunal Chowdhury «IN»11-Jan-11 22:15 
GeneralRe: My vote of 5 Pin
Selvin12-Jan-11 4:30
Selvin12-Jan-11 4:30 
GeneralRe: My vote of 5 Pin
Kunal Chowdhury «IN»12-Jan-11 5:10
professionalKunal Chowdhury «IN»12-Jan-11 5:10 
GeneralMy vote of 5 Pin
JF201511-Jan-11 21:29
JF201511-Jan-11 21:29 
GeneralRe: My vote of 5 Pin
Kunal Chowdhury «IN»11-Jan-11 21:58
professionalKunal Chowdhury «IN»11-Jan-11 21:58 
GeneralMy vote of 5 Pin
Brij11-Jan-11 19:52
mentorBrij11-Jan-11 19:52 
GeneralRe: My vote of 5 Pin
Kunal Chowdhury «IN»11-Jan-11 21:18
professionalKunal Chowdhury «IN»11-Jan-11 21:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.