Skip to main content Skip to footer

Customizing C1Themes Dynamically in WPF Edition

Background:

When a theme is applied to the application/control, all styles of the theme get applied to the application/control. However, at run time one might want to override only few of the style related properties specific to a control on which the theme is already applied.

The product sample ‘CustomThemes ->Extending Themes’ shows how to extend a theme. But it only overrides properties that are generic to all controls.

This article extends the product sample ‘CustomThemes’ by demonstrating how to dynamically extend a theme by overriding few of its control specific styles.

Steps to Complete:

1. Using the sample in the above description, customize the theme style for specific controls by modifying the code in the Part_ExpressionDarkOverrides.xaml file as follows. Here, we define SelectedBackground color only for controls of the type C1ComboBox

2. In the above code, R, R1, G, G1, B, B1, A, A1 are resources defined at the application level.

3. To dynamically override the theme, invoke the Apply method of the custom theme. As the values of application resources change at run time, the custom theme will reflect the changes (just call the Apply method every time).

Ruchir Agarwal