Skip to content

Commit f4744bc

Browse files
authored
Merge pull request #712 from telerik/nkaraiva/default-theme-new-updates
Revise and update Default theme article in docs
2 parents 01edc4b + 618c2fe commit f4744bc

File tree

5 files changed

+38
-38
lines changed

5 files changed

+38
-38
lines changed

styling-and-appearance/default-theme.md

+38-38
Original file line numberDiff line numberDiff line change
@@ -10,110 +10,110 @@ position: 1
1010

1111
# Default Theme
1212

13-
All RadControls from the Telerik UI for WinForms suite get the **ControlDefault** theme applied to them by default if no other theme is set.
14-
15-
>caption ControlDefault theme
13+
Telerik UI for WinForms comes with a set of built-in themes that enhance the visual appearance of the components, helping you achieve an outstanding look of your application. Each theme determines the colors, borders, backgrounds, size, layout, position, font, font size, etc of the components.
1614

17-
![default-theme001](images/default-theme001.png)
15+
All RadControls from the Telerik UI for WinForms suite get the **ControlDefault** theme applied to them by default if no other theme is set. If you create a new Windows Forms App, then drag any RadControl from the Toolbox and drop it onto the form, the **ControlDefault** theme should be automatically applied.
1816

19-
If you drag a control from the toolbox and drop it onto the form, the **ControlDefault** theme is applied as well.
20-
21-
>caption Design time - default theme
17+
>caption Design time - ControlDefault theme
2218
2319
![default-theme002](images/default-theme002.png)
2420

25-
Using the [built-in themes]({%slug winforms/themes/using-default-themes%}) that come out of the box with the installation of the Telerik UI for WinForms suite, you can apply a different theme for the specific control.
26-
2721
## Fluent theme as Default
2822

29-
As of **R1 2021**, it is possible to define which theme is your **default theme** (e.g. **ControlDefault**) for the controls even at design time. This can be defined in the App.config file as follows:
23+
As of **R1 2021**, Telerik UI for WinForms starts using **Fluent** theme as default as it provides more modern and fresh look. If you create a new Telerik Windows Forms Application, then drag any RadControl from the Toolbox and drop it onto RadForm, the **Fluent** theme should be automatically applied .
3024

25+
**Fluent** theme is defined in the **App.config** file as follows:
3126

3227
````XML
3328

3429
<?xml version="1.0" encoding="utf-8"?>
3530
<configuration>
3631
<startup>
37-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
32+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
3833
</startup>
39-
4034
<appSettings>
4135
<add key="TelerikWinFormsThemeName" value="Fluent" />
4236
</appSettings>
4337
</configuration>
4438

4539
````
4640

47-
>caption Fluent theme as default
41+
>caption Design time - Fluent theme
4842
4943
![default-theme003](images/default-theme003.png)
5044

5145

52-
>important The **Fluent** theme is now a part of the **Telerik.WinControls** assembly and it is statically available everywhere just like the **ControlDefault** theme. As a result, it is no longer necessary to instantiate the **FluentTheme** type.
46+
>note **Fluent** and **ControlDefault** themes are both included in the **Telerik.WinControls** assembly. They are available at any time, and it is not necessary to reference them explicitly in the project references.
5347
54-
>note The **Telerik.WinControls.Themes.Fluent** assembly is still available and it remains for compatibility so that existing projects don't break when they upgrade.
5548

56-
>note The theme settings are being read upon opening the first form designer in the project. If you change the default theme in App.config, it is necessary to **close all opened designers and open them again**.
49+
## Other Telerik theme as Default
5750

58-
We are using the above App.config in the VS templates, so that new Telerik projects created by the Visual Studio extension have the Fluent theme set as default.
51+
All Telerik themes that Telerik UI for WinForms offers, can be used as default theme in the application either at design time and run time. You can check other themes styles [here](https://docs.telerik.com/devtools/winforms/styling-and-appearance/themes-style).
5952

60-
## Other Telerik theme as Default
53+
To use any Telerik theme you should follow these two steps below :
54+
1. Add the relevant theme assembly to the project references. For example, if you prefer using the Windows11Compact theme in your application, you should add a reference to the **Telerik.WinControls.Themes.Windows11** in your project. You can do this by either drag-drop the theme from the Toolbox or reference it from your installation folder.
6155

62-
All Telerik themes are supported with the above API, it is, however, necessary that the project references the correct assembly, e.g. add reference to Telerik.WinControls.Themes.Material and in the App.config set:
56+
>note When you use the **UI.for.WinForms.AllControls** Telerik NuGet package, all the available themes are included in the package.
57+
58+
2. Specify the TelerikWinFormsThemeName in the **App.config** file:
6359

6460
````XML
6561

66-
<?xml version="1.0" encoding="utf-8"?>
62+
<?xml version="1.0" encoding="utf-8" ?>
6763
<configuration>
6864
<startup>
69-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
65+
7066
</startup>
71-
7267
<appSettings>
73-
<add key="TelerikWinFormsThemeName" value="Material" />
68+
<add key="TelerikWinFormsThemeName" value="Windows11Compact" />
7469
</appSettings>
7570
</configuration>
7671

7772
````
7873

79-
If the user sets a valid Telerik theme name (other than Fluent and ControlDefault) as default, but the project misses the theme assembly reference, the following message appears:
80-
81-
![default-theme004](images/default-theme004.png)
74+
Once, the two steps are completed, you can close and reopen the designer file again to ensure the theme is applied:
8275

83-
Once the necessary assembly is referred, the designer loads with the correct design:
76+
>caption Design time - Windows11Compact theme
8477
8578
![default-theme005](images/default-theme005.png)
8679

87-
>note In order to use the Theme components, just drag and drop them from the VS Toolbox to the form. This will add a reference to the corresponding theme assembly in the project and will enable the theme in the **ThemeName** drop-down of all Telerik controls on the form.
80+
### Missing Assembly Reference Message
81+
82+
If it happens that a valid Telerik theme name is used in the App.config, but the project misses the theme assembly reference, the following message will appear indicating missing assembly reference when you try to load the designer:
83+
84+
![default-theme004](images/default-theme004.png)
85+
86+
Theme settings are read upon opening the form designer in the project for the first time. If you change the default theme in App.config, it might be necessary to close all opened designers, then open them again to ensure the newest changes are kept in Visual Studio.
8887

8988
## Custom theme as Default
9089

91-
Since it is possible to build your own [custom style]({%slug winforms/themes/using-custom-themes%}), it is possible to specify this theme as default. We will use the same API to load client's themes defined in their own assemblies: [Creating a theme component]({%slug winforms/themes/advanced-topics/adding-custom-redistributable-themes-to-your-application-/creating-a-theme-component%})
90+
It is also possible to set a client's custom theme as default theme in an application. As we provide an apportunity for our clients to build their own [custom style]({%slug winforms/themes/using-custom-themes%}) theme, we can use the same API to load client's theme defined in their own assemblies: [Creating a theme component]({%slug winforms/themes/advanced-topics/adding-custom-redistributable-themes-to-your-application-/creating-a-theme-component%})
9291

93-
>note With the __2024 Q2__ version of our controls it is necessary to use the assembly fully qualified name when defining it inside the App.config.
92+
>note To use a custom theme as default it is necessary to use the assembly fully qualified name inside the App.config. Also, it is important to create an instance of the newly created theme.
9493
95-
Imagine a client creates a theme with name **LightCoral**. Besides the theme name, the App.config will also need the theme type and theme assembly name.
94+
Let's say there is a custom **Windows11CompactLightBlue** theme created, which is a variation of the basic Windows11Compact theme. Besides the theme name, the App.config will also need the theme type and theme assembly name, version, culture, and public key token:
95+
96+
>caption Design time - Custom Windows11CompactLightBlue theme
9697
9798
![default-theme006](images/default-theme006.png)
9899

99100
````XML
100101

101-
<?xml version="1.0" encoding="utf-8"?>
102+
<?xml version="1.0" encoding="utf-8" ?>
102103
<configuration>
103104
<startup>
104-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
105105
</startup>
106-
107106
<appSettings>
108-
<add key="TelerikWinFormsThemeName" value="LightCoral" />
109-
<add key="TelerikWinFormsThemeType" value="LightCoralClassLibrary.LightCoralTheme"/>
110-
<add key="TelerikWinFormsThemeAssemblyName" value="LightCoralClassLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9aa2a467bbfe794e"/>
107+
<add key="TelerikWinFormsThemeName" value="Windows11CompactLightBlue" />
108+
<add key="TelerikWinFormsThemeType" value="Windows11LightBlueClassLibrary.Windows11LightBlue"/>
109+
<add key="TelerikWinFormsThemeAssemblyName" value="Windows11LightBlueClassLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
111110
</appSettings>
112111
</configuration>
113112

114113
````
115114

116-
Thus, if you drag a new **RadButton** from the Toolbox, it will be with the LightCoral theme applied.
115+
>important Full tutorial demonstrating the exact setup of the above example is available in the following KB article: [Custom theme as default](https://testdocs.telerik.com/devtools/winforms/knowledge-base/custom-theme-as-default).
116+
Complete projects in .NET9 and NET Framework 48 are available in our SDK repo [here](https://github.com/telerik/winforms-sdk/tree/master/Themes/CustomThemeAsDefault).
117117

118118
## See Also
119119

Binary file not shown.
Loading
Loading
Loading

0 commit comments

Comments
 (0)