Getting Started with WPF | ComponentOne Studio Edition
Theming / Applying Themes to Controls / Applying Themes to MS Ribbon Control
In This Topic
    Applying Themes to MS Ribbon Control
    In This Topic

    You can also apply themes to your standard Microsoft Ribbon control for WPF by using C1.WPF.Theming.Ribbon. The following steps illustrate applying themes to the MS Ribbon control.

    1. Add following namespace in the xaml file and create application to add MS Ribbon control.

      XAML
      Copy Code
      xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"
      

    2. Add following code to apply themes to ribbon control.

      Visual Basic
      Copy Code
      Private Sub ApplyTheme(name As String)
                   Dim theme As C1Theme = Nothing
                   Dim ribbonTheme As C1Theme = Nothing
                  Select Case name
                       Case "Cosmopolitan"
                          ribbonTheme = New C1.WPF.Theming.Ribbon.C1ThemeRibbonCosmopolitan()
                           Exit Select
                       Case "Cosmopolitan Dark"
                          ribbonTheme = New C1.WPF.Theming.Ribbon.C1ThemeRibbonCosmopolitanDark()
                           Exit Select
                       Case "Office2013 White"
                          ribbonTheme = New C1.WPF.Theming.Ribbon.C1ThemeRibbonOffice2013White()
                           Exit Select
                       Case "Office2013 LightGray"
                          ribbonTheme = New C1.WPF.Theming.Ribbon.C1ThemeRibbonOffice2013LightGray()
                           Exit Select
                       Case "Office2013 DarkGray"
                          ribbonTheme = New C1.WPF.Theming.Ribbon.C1ThemeRibbonOffice2013DarkGray()
                       Case Else
                           Exit Select
                   End Select
                   'apply  ribbon theme
                   ribbonTheme.Apply(ribbon)
               End Sub
      
      C#
      Copy Code
      private void ApplyTheme(string name)
      {
          C1Theme ribbonTheme = null;
          switch (name)
          {
              case "Cosmopolitan":
                  ribbonTheme = new C1.WPF.Theming.Ribbon.C1ThemeRibbonCosmopolitan();
                  break;
              case "Cosmopolitan Dark":
                  ribbonTheme = new C1.WPF.Theming.Ribbon.C1ThemeRibbonCosmopolitanDark();
                  break;
              case "Office2013 White":
                  ribbonTheme = new C1.WPF.Theming.Ribbon.C1ThemeRibbonOffice2013White();
                  break;
              case "Office2013 LightGray":
                  ribbonTheme = new C1.WPF.Theming.Ribbon.C1ThemeRibbonOffice2013LightGray();
                  break;
              case "Office2013 DarkGray":
                  ribbonTheme = new C1.WPF.Theming.Ribbon.C1ThemeRibbonOffice2013DarkGray();
                  break;
              default:
                  break;
          }
      // apply  ribbon theme
          ribbonTheme.Apply(ribbon);
      }