Edit this page

Using a default theme for the entire application

When your application has many and different controls, you may find it inconvenient to go through all the controls in order to set their ThemeName property. For such cases, set the static ThemeResolutionService.ApplicationThemeName property to a theme name:

Setting a theme for the entire application

ThemeResolutionService.ApplicationThemeName = "Office2007Black";

ThemeResolutionService.ApplicationThemeName = "Office2007Black"


You still have to drop the theme component on the form (e.g. Office2007Black in the code samples above) or create an instance of the desired theme programmatically. As the static ApplicationThemeName property affects the whole application this needs to be done only once. A suitable place is the constructor of the first form used in the application.

All your controls will use that specified theme which has precedence over the theme set locally to the control using ThemeName property.

Enable/Disable the globally set theme for a specific control

This section describes how you can change the theme for the entire application and leave the default one (or use another) for one or several controls. This can be achieved by using the EnableApplicationThemeName property.

This property indicates how the theme will be set to the control. If it is set to true (the default value) the control will have the theme that is globally set (with the ApplicationThemeName property). If it is set to false, the theme, set with the ThemeName property will be respected. For example, you can set the theme for the entire application except for one RadGridView control as follows:

ThemeResolutionService.ApplicationThemeName = "Office2010Blue";
radGridView1.ElementTree.EnableApplicationThemeName = false;
radGridView1.ThemeName = "Office2010Silver";

ThemeResolutionService.ApplicationThemeName = "Office2010Blue"
RadGridView1.ElementTree.EnableApplicationThemeName = False
RadGridView1.ThemeName = "Office2010Silver"

Figure 1: The theme of the grid is different than the application theme.

themes-using-a-default-theme-for-the-entire-application 001

You can watch the video Telerik UI for for WinForms Theme regarding the usage of theme components and ApplicationThemeName property.

See Also