This is a migrated thread and some comments may be shown as answers.

New custom theme to make stand alone

3 Answers 131 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 02 Aug 2008, 01:50 AM
Hi telerik,

I have several custom theme. How do I make it standalone like standalone telerik theme in current version?


Thanks

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 04 Aug 2008, 02:06 PM
Hello Erik,

Thank you for your interest in RadTheming.

It is very easy for implementation in custom controls.
1) Create New Project of type Class library.
2) Add all themes XML files into this project  and choose for each in properties Build Action: Embedded Resource
3) The main class in the project (usually Class1) must inherit Component or RadThemeComponentBase
public class Class1 : Component
4) Add the following line for each theme file into the class Constructor ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource,                                                  @"ClassLibrary1.MyButtonTheme.xml");
Here is a snapshot from our Aqua theme
namespace Telerik.WinControls.Themes
{
    [Description("Enables Aqua theme for the controls in your application")]
    [ToolboxItemFilter("System.Windows.Forms")]
    public class AquaTheme: RadThemeComponentBase
    {
        public AquaTheme()
        {
            ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource,
                                                            @"Telerik.WinControls.Themes.Button.xml");
....
This component will appear in the Visual Studio toolbox and will be available for drag&drop over existing forms.

Hope this will clear how the themes work as components.

Greetings,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Johan
Top achievements
Rank 1
answered on 15 Aug 2008, 01:05 PM
Hello, I have tried doing this but it doesn't seem to work.

This is my code:

namespace Telerik.WinControls.Themes  
{  
    [Description("Enables Aqua theme for the controls in your application")]  
    [ToolboxItemFilter("System.Windows.Forms")]  
    public class Class1 : RadThemeComponentBase  
    {  
        public Class1()  
        {  
            ThemeResolutionService.RegisterThemeFromStorage(ThemeStorageType.Resource, @"Telerik.WinControls.Themes.Class1.Office2007Silver.xml");  
        }  
    }  

I have compiled the project (that I added as a Class Library) and added the component Class1 to my form, but I am unable to set the theme to Office2007Silver.
0
Vassil Petev
Telerik team
answered on 18 Aug 2008, 01:37 PM
Hi Johan,

The code snippet from Peter's post is just a snapshot of the Aqua theme component. You do not need to use Telerik.WinControls.Themes namespace in your custom theme components.

Your theme component is not working most probably because you are giving an incorrect path to the xml theme file. Generally, the string for the path is constructed as it follows: ProjectDefaultNamespace.ContainingFolder.ThemeFileName.xml. The ContainingFolder is only needed if the xml files are in folders in the project structure.

I have attached a sample project which demonstrates how a ThemeClassLibrary is created and used.

Contact me again, if you have additional questions.
 

Regards,
Vassil
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Themes and Visual Style Builder
Asked by
Erik
Top achievements
Rank 1
Answers by
Peter
Telerik team
Johan
Top achievements
Rank 1
Vassil Petev
Telerik team
Share this question
or