Spruce up your next application with the WPF Ribbon


Microsoft Office 2007 delivered a bold replacement for the tired menu bar known simply as the Ribbon.  Up until recently, the Ribbon was exclusive to Microsoft applications; however, Microsoft has now made the WPF(Windows Presentation Foundation) Ribbon available through the Office UI Licensing.  This license in effect allows you to incorporate the WPF Ribbon as well as the Office 2007 styling into your application. I should point out, that you will need to register to download the WPF Ribbon control and essentially agree not to create an Office 2007 competitive application. Using the WPF Ribbon within your application provides the following UI elements:

  • The Application Button is the round button in the upper left. Its purpose is to provide access to the Application Menu which includes one or more menu items.
  • The Quick Access Toolbar provides convenient access to common functions.
  • Tabs provide high level grouping for items within the Ribbon. Within each tab, multiple Groups exists to provide further categorization. Inside each Group is where the individual controls exist.

After downloading the Ribbon Control, create a WPF Application project and add a reference to the RibbonControlLibrary. Next, we need to modify the existing Window to start creating the Ribbon. To get started, we need to modify the XAML(eXtensible Application Markup Language) to modify the window and create a blank Ribbon. The XAML to create the window with the empty ribbon is listed below:

  <my:RibbonWindow x:Class="WPFRibbonExample.Window1" 
     Title="WPF Ribbon Example" 
     Height="374" Width="633" 
              <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml"/>
        <my:Ribbon DockPanel.Dock="Top" Name="ribbon1" Height="138" Title="WPF Ribbon Example" VerticalAlignment="Top">

If you execute the application at this point, you should see the screen as shown below:

Empty Ribbon
Click here for larger image

Figure 1 - Empty Ribbon

This basic XAML above is slightly different from a standard Window. The window tag itself is replaced with a RibbonWindow which provides additional functionlity necessary for the Ribbon UI. Next we pull in the Office 2007 Blue styling and finally create a blank Ribbon inside a DockPanel. Next we'll focus on creating the necessary elements within the Ribbon. Insert the following XAML inside the Ribbon tag.

  <my:RibbonTab Label="File"> 
  <my:RibbonTab Label="View" /"> 

At this point, the ribbon should show 2 tabs, File and View as shown below.

File and View Tabs
Figure 2 - File and View Tabs

Next we create a group and finally the individual controls. The following XAML snippet should be inserted into the RibbonTab tag.

  <my:RibbonGroup Name="FileOperations">
        <my:RibbonCommand LabelTitle="File Operations" ></my:RibbonCommand> 

This will create an empty File Operations Group and assign a label to it. This is done through the RibbonCommand class. Next we need to start creating buttons within the group. Before we start creating buttons, it is a good idea to start planning the commands for the Ribbon. Each command the ribbon will perform should be created as a Ribbon Resource so it can be reused for buttons on the Ribbon and Quick Access toolbar or within the Application Menu. Below is a simple Open RibbonCommand Resource which is to be inserted within the Ribbon tag.

     <my:RibbonCommand x:Key="OpenCommand" 
        Executed="OpenCommand_Executed" /> 

Spruce up your next application with the WPF Ribbon

The images refereced above are used to display the body of the button. The large image is a 40x40 PNG with transparency. This image is used for buttons on the Ribbon as well as menu Items within the Application Menu. The small image is a 20x20 PNG with transparency. This image is used when the window size is changed to shrink the Ribbon as well as for the Quick Access toolbar. Also, be sure to create an OpenCommand_Executed method in the code behind to capture the click events. Next, Insert the following XAML snippet into the File Operation Ribbon Group.

  <my:RibbonButton Name="Open" Command="{StaticResource OpenCommand}"/>

This change will create an Open button and associate the OpenCommand, created above with it as shown below.

Open Button
Click here for larger image

Figure 3 - Open Button

Now that we have a basic Ribbon, we can start to populate the Application Menu. Insert the following snippet into the Ribbon tag.

     <my:RibbonApplicationMenu Name="AppMenu"> 
           <my:RibbonCommand LabelTitle="WPF Ribbon Example" LargeImageSource="Images\Round2.png" />
        <my:RibbonApplicationMenuItem Name="MenuOpen" Command="{StaticResource OpenCommand}"/>

This XAML will create the Application Menu, Assign the Application Button and create an Open Menu Item.  The Round2.png image is a 36x36 pixel image with transparency. Below is an image of the Application Menu at this point.

Application Menu
Click here for larger image

Figure 4 - Application Menu

Finally, to create the Quick Access toolbar we insert the following snippet into the Ribbon tag.

        <my:RibbonButton Name="QLOpen" Command="{StaticResource OpenCommand}"/> 

This will create a single Open button within the Quick Access Toolbar as shown below:

Quick Access Toolbar

Figure 5 - Quick Access Toolbar


The WPF Ribbon provides a wide range of functionality including additional controls, popup dialogs, control galleries and the ability to control how the ribbon shrinks when the window is resized. Using the WPF Ribbon within your application can drastically improve the usability of your application and provide a familiar user interface to those who use Office 2007.

Download the example source code by clicking here.

About the Author

Chris Bennett is with Crowe Horwath LLP in the Indianapolis office. He can be reached at chris .bennett@crowehorwath.com

About the Author

Chris Bennett

Chris Bennett is a Manager with Crowe Horwath LLP in the Indianapolis office. He can be reached at chris.bennett@crowehorwath.com.


  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Live Event Date: December 18, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this upcoming webcast …

Most Popular Programming Stories

More for Developers

RSS Feeds