Sparkline for WPF
Styling and Appearance / Apply Themes
In This Topic
    Apply Themes
    In This Topic

    Sparkline supports built-in ComponentOne themes available in C1.WPF.Theming library. You can apply any of the available C1 themes to the Sparkline control and provide a customized and consistent appearance to the application.

    WPF Sparkline with Theme

    The following steps illustrate how to apply C1 themes to Sparkline. This example uses the sample created in the Quick start.

    1. Add the following assembly references to your application.

      • C1.WPF.Theming
      • C1.WPF.Theming.ShinyBlue
    2. Create a class named MyTheme to return an object of the C1Themes class.

      C#
      Copy Code
      public class MyThemes
      {
          private static C1Theme _myTheme = null;
          public static C1Theme MyTheme
          {
              get
              {
                  if (_myTheme == null)
                  {
                      _myTheme = new C1ThemeShinyBlue();
                  }
      
                  return _myTheme;
              }
          }
      }
      
    3. Subscribe to the Sparkline_Loaded event and add the following code to the Sparkline_Loaded event handler to apply the theme to the Sparkline control.

      C#
      Copy Code
      //Apply C1 theme to Sparkline 
      C1Theme.ApplyTheme(sparkline, MyThemes.MyTheme);