How to customize the WPF Ribbon 4.5 (styles, templates, etc.)

Alexander Zwitbaum picture Alexander Zwitbaum · Jul 5, 2013 · Viewed 9.1k times · Source

I try to customize System.Windows.Controls.Ribbon from the .Net Framework 4.5 so it can be used with the Expression Dark theme (dark colors like in default theme of the Blend). I've tried following ideas, but until now without any progress:

  • change the Background of the ribbon: will change only the main Color, but leaves all other glossy colors, highlight colos etc.
  • change the styles and templates: I couldn't find any default templates for the Ribbon 4.5. I've tried to get them via Tools like ShowMeTheTemplate, but it seems that they use some internal classes.
  • customizing the templates with Blend for VS2012: I get always an error "Copy Template failed."
  • use the .net 4 ribbon from the RibbonControlLibrary: the RibbonWindow Looks ugly in the Windows 8 (see WPF RibbonWindow + Windows 8 - control box looks bad), that I can't solve

Any help would be appreciated, all suggestions are welcome.

Answer

Andreas Kahler picture Andreas Kahler · Nov 17, 2014

I was able to extract a fully working template using Show me the templates. To do that I modified it to extract templates from "System.Windows.Controls.Ribbon" (rather than the main framework assembly).

It gives me the following:

https://gist.github.com/drayde/75526b570a266f5f8f38 (too long to paste here)

Just add this to your resources and use it like this:

    <Ribbon Template="{StaticResource ribbonTemplate}">
       ...
    </Ribbon>

By modifying the template you should have full control over how your ribbon is displayed.