Home / Community & Support / Knowledge Base / RadControls for WinForms / Themes and Styling / Adding custom redistributable themes to your applications

Adding custom redistributable themes to your applications

Article Info

Rating: 5

Article information

Article relates to

RadControls for WinForms, Q2 SP1 2007 

Created by

Nikolay Diyanov    

Last modified

Dec. 11, 2007

Last modified by

Nikolay Diyanov



HOW-TO
Add custom themes to your applications in a way that allows them to be redistributable

SOLUTION
The purpose of this article is to familiarize you with the ways to add custom themes to your applications, so that they are reusable and redistributable. At the end of this article you will find links for three videos that demonstrate the approaches described.

Creating a theme component:

The recommended approach to add custom redistributable themes to your applications is by using a theme component. Full instructions on this approach you can find in the Creating a theme component KB Article.

    Adding a custom theme as a file:

    1. Create a new Windows Application and drag a RadControl, i.e. RadButton, from your Toolbox to your form.
    2. Create a new custom theme and save it somewhere on your hard drive.
    3. Right-click the project node in the Solution Explorer, choose Add >> Existing Item and add the custom theme file. This will automatically copy the custom theme file in your project's directory.
    4. Add a RadThemeManager to the form.
    5. From its Action Menu (click the Smart Tag to open it) choose Load Theme from file, then browse to the theme file in the project directory and select it, click Open.
    6. Again from the RadThemeManager's Action Menu, choose Edit Themes, set the ThemeLocation property according to the following pattern: "~..\..\ThemeFileName.Extention", assuming that the theme file is in the directory where the project executable is built.
    7. Now apply the theme to the RadButton.

    Adding a custom theme as a resource:

    1. Create a new Windows Application, drag a RadControl, i.e. RadButton, from your Toolbox to your form.
    2. Create a new custom theme and save it somewhere on your hard drive.
    3. Right-click the project node in the Solution Explorer, choose Add >> Existing Item and add the custom theme file. This will automatically copy the custom theme file in your project's directory. You can also add a new folder (Add >> New Folder) where you can put your custom theme.
    4. Set the custom theme's Build Action property to Embedded Resource.
    5. Add a RadThemeManager to the form.
    6. From the RadThemeManager's Action Menu (click the Smart Tag to open it) choose Load Theme from resources.
    7. You will be prompted to enter the resource location. C# and VB.NET compilers differ from one another, so:
      • In a C# application the pattern is ProjectDefaultNamespace.FolderName.ThemeFileName.Extention if the theme file is in a folder as mentioned in step 3, otherwise it is just ProjectDefaultNamespace.ThemeFileName.Extention
      • In a VB.NET application, it does not matter whether the theme file is in a folder or not, the pattern is always the same: ProjectRootNamespace.ThemeFileName.Extention.
    8. Build the application. This will include the custom theme file in your assemblies.
    9. Now you can apply the theme to the RadButton.
    10. Note: To be sure about the theme resource location in step 7, you can use Reflector. After building the project simply reflect the built assembly/executable and you will see it.

     

    Comments

    If you'd like to comment on this KB article, please, send us a Support Ticket.
    Thank you!

    Please Sign In to rate this article.