Please note that the theme properties can not be changed in the program either at design time or at runtime. You can customize a theme by using the C1ThemeDesigner and then saving the theme again with the changes.
So that means for a label that I need to change the forecolor, I have to either apply a different custom theme either not apply the theme and define all properties in the designer/code.
Although this is not directly possible, as a workaround you can use the following method to change any color for the specified theme for the whole application:
private bool SetColorProperty(string themeName, string propPath, Color color)
{
// Get theme by name.
var theme = C1ThemeController.GetThemeByName(themeName, false);
if (theme != null)
{
// Get the color property at the specified path.
var prop = theme.Children.GetItemByPath(propPath) as ColorProp;
if (prop != null)
{
prop.Value = color;
return true;
}
}
return false;
}
You can get the path for the desired property from the C1ThemeDesigner, Please refer to the sample and image attached.
If you want to apply the theme to specific labels then you can use the C1ThemeController.ApplyThemeToControlTree() method to apply specific themes to a control. You will need to use different themes for different styles. ```
Or You can apply the theme to the whole application and then change the ForeColor property of specific labels that you want with a different ForeColor.
Regards.
Avnish
you can also implement the interface “C1.Win.C1Themes.IC1Themeable” on specific forms/user controls to :
a) prevent the setting of theme to this control (property"AllowThemeChange")
b) do changes after the theme was set (method “OnThemeChanged”).
To prevent applying the theme to specific controls, you can use the method “C1ThemeController.ApplyThemeToControlTree” and provide the optional parameter “applyThemeToSubTree”: this one is called for each control and can return “false” for some controls that should not be themed.