3 Answers, 1 is accepted
0
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.
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:
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.
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
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.
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.