Click here to Skip to main content
15,613,873 members
Articles / Desktop Programming / WPF
Posted 27 Jun 2014


36 bookmarked

A Windows 8 WPF Ribbon

Rate me:
Please Sign up or sign in to vote.
4.82/5 (21 votes)
3 Jul 2014CPOL3 min read
The article showcases a Windows 8 themed WPF Ribbon inspired by Office 2013 and Visual Studio 2013.


Although Microsoft is focused on it's RT platform some development is still done using WPF.
Unfortunately the current WPF Ribbon looks aged and lackluster, hope for a new version is probably in vain. Unhappy with the current state of affairs I sat down on a weekend and implemented a
simple window control based on the current Office 2013 style with a pinch of Visual Studio sprinkled in.
Although it will look very similar to both Office and Visual Studio a keen eye will spot the differences, if you're looking for an exact copy it should be easy enough to make the alterations yourself.

You can download the source from GitHub.

Using the code

Using the code is pretty straight forward and very similar to the current WPF Ribbon implementation.

The Window

In addition to the obvious foreground and background properties there are two additional properties that affect the appearence. The HoverBrush allows you to set the brush used when a mouse over event occurs on the ribbon and the AccentBrush does set the accent color of the window, obviously.
The code below shows you how the basic window is declared.

<ui:RibbonWindow x:Class="Crystalbyte.MainWindow"
  <ui:ApplicationMenu />
  <ui:Ribbon />
 <Grid />

One difference to the standard WPF Microsoft Ribbon Control is the fact that the status bar is an integral part of the window.

Image 1

The window comes with the new office tri-state button to switch between "tab only", "fullscreen" and "tabs & commands" views.

Image 2

The Ribbon

The ribbon is the simplest control since there is little to do but to add tabs. You can however set the text that is displayed inside the application menu button from here.

<ui:Ribbon x:Class="Crystalbyte.Ribbon"
    <local:SomeTab />

The Ribbon Tab

The ribbon tab differs slightly from the current MS implementation as it requires a RibbonPage to wrap the RibbonGroups. Apart from that you won't find much differences.

<ui:RibbonTab x:Class="Crystalbyte.Ribbon.SomeTab"
            <ui:RibbonButton Command="..."  />
            <ui:RibbonButton Command="..."  />

The Application Menu

Similar to the Office 2013 style the application menu is wired directy into the window and handles pretty much the same. The current implementation brings three controls for the application menu to the table.

<ui:ApplicationMenu x:Class="Crystalbyte.Ribbon.SomeMenu"
    <ui:ApplicationMenuItem Header="Some Menu">
        <TextBlock>Some Content</TextBlock>
    <ui:ApplicationMenuSeparator />
    <ui:ApplicationMenuButton Command="..." />

The ApplicationMenuItem displays its content in the application menu zone which encompasses the entire window. The seperator and the button should be self explanatory.

Image 3

Everything put together

The demo project shows a simple, but complete implementation and looks pretty much like this.

Image 4

The theme operates on the Windows 8 accent based system. You can choose a background color for the window and an accent, which then gets adopted by all ribbon child controls.

As can be seen on the screenshot above a tab can also have a contextual state, controlled by a simple property "IsContextual" and the dedicated brush property "ContextualBrush".

To keep the implementation small and clean I decided not to support multiple tabs in a single context, since it would have required massive changes to the basic framework controls used in the ribbons construction.
I explicitly wanted to avoid creating any custom controls which is the reason why the ribbon is merely a massively styled TabControl.

The last thing on the list is the embedded support to add quick access items to the upper window bar, which do persist on application shutdown.

I hope some of you can benefit from the project, if any one has suggestions or corrections I gladly accept pull request to the main repository on GitHub.

Points of Interest

Once you drop the default window border you obviously lose some functionality as well, such as Aero Snap, Auto Resize and the default Window Buttons. While developing the control the hardest part was wrapping my head around WPF's DPI aware sizing system, especially setting the window bounds by hand when dealing with different window border sizes and themes on Windows 7 & Windows 8 was tough.


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

Written By
Software Developer Crystalbyte
Germany Germany
I took my first C++ class when I was 12, unfortunately pointer arithmetics don't go hand in hand with small children.
While studying for my bachelor in informatics, I'm currently freelancing at a small software company with focus on the .NET Framework.

A Bro must always post bail for another Bro, unless it's out of state or, like, crazy expensive.

Crazy Expensive Bail > (Years You've been Bros) * $100

Alexander Wieser

Comments and Discussions

QuestionBinding StatusBarItemsSource messages Pin
souitom4-Jun-20 2:48
souitom4-Jun-20 2:48 
PraiseGreat library! Pin
DWaters6-Jan-16 1:15
DWaters6-Jan-16 1:15 
QuestionI miss a ribbon feature Pin
Enno7915-Sep-15 23:00
Enno7915-Sep-15 23:00 
GeneralGreat Work Pin
Member 77734648-Jun-15 23:33
Member 77734648-Jun-15 23:33 
Questionplease post some virustotal scanner in .net Pin
Member 105796733-Jul-14 17:37
Member 105796733-Jul-14 17:37 
GeneralMy vote of 5 Pin
Lars Holznagel3-Jul-14 10:16
Lars Holznagel3-Jul-14 10:16 

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.