|
Article relates to
|
RadControls for WinForms
|
|
Created by
|
Nikolay Diyanov
|
|
Last modified
|
Sep 16, 2008
|
|
Last modified by
|
Nikolay Diyanov
|
INTRODUCTION
Since Q2 2008, a new approach for using all the Telerik predefined themes was introduced. It represents isolating a set of themes in a separate class library project. This class library project is actually the theme component, which you can later use in your main project. This approach greatly simplifies the way of adding and removing themes to your project and helps in displaying the themes in design-time.
HOW-TO
Create a RadControls for WinForms theme component
SOLUTION
Here are the steps to create and use a new theme component:
- Add a new Class Library project to your current solution.
- Add your theme files and set their Build Action to Embedded Resource.
- Add a new class to represent your theme component to the project:
C#
| public class EnterpriseBlack : Component |
| { |
| public EnterpriseBlack() |
| { |
| ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource, |
| @"ProjectDefaultNameSpace.FolderName.ThemeName1.xml"); |
| ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource, |
| @"ProjectDefaultNameSpace.FolderName.ThemeName2.xml"); |
| } |
| } |
VB.NET
| Public Class EnterpriseBlack |
| Inherits Component |
| |
| Public Sub New() |
| MyBase.New |
| ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource, "ProjectDefaultNameSpace.FolderName.ThemeName1.xml") |
| ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource, "ProjectDefaultNameSpace.FolderName.ThemeName2.xml") |
| End Sub |
| End Class |
| |
| |
Please note that your class should inherit Component. As to the path string, it is constructed as follows: ProjectDefaultNamespace.ContainingFolder.ThemeFileName.xml. The ContainingFolder is only needed if the xml files are in folders in the project structure (C# only). Regarding VB.NET, even if the theme file is in a folder, you should not include the folder name in the path string.
- When you compile the project, you will be able to drag the this component to the forms in all the projects in you solution which will load the corresponding theme, both runtime and designtime.
A sample project demonstrating the approach is attached below. In it we have a project, named EnterpriseBlack where the theme is in a EBlackThemesFolder.
Please
Sign In
to rate this article.