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

What the best way to use a custom theme?

3 Answers 259 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Giovanni asked on 25 Oct 2012, 01:32 PM
Hi, I'm trying to build a custom theme to use over all my application.
I stardet from an existing theme, as suggested, and I've build my custom them as a tssp file.

I added the tssp to my project and I setted it as application theme:

ThemeResolutionService.LoadPackageResource("MyProject.MyCustomTheme.tssp")
ThemeResolutionService.ApplicationThemeName = "MyCustomTheme"

When I build and I run the application, all the forms and controls appears with my custom theme, and this is very good.
But at design time, using the visual studio form editor I don't see my theme.
How can I see my theme even in design time?

Do I have to load the same theme using a RadThemeManager (from the xml equivalent files) and set the ThemeName property for all controls?
If yes, which is the utility of using the ApplicationThemeName property?

Thank you.

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 30 Oct 2012, 03:23 PM
Hello Giovanni,

Thank you for writing.

In order to load a theme in design time you need to create a component from it. Attached you can find a sample project demonstrating how to do that.

Let me know if you have any additional questions regarding this matter.
 
Kind regards,
Stefan
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
answered on 31 Oct 2012, 08:40 AM
Thank you Stefan,
I tried your example but I have some troubles.

First, it works fine in design mode, but it doesn't work at running time (please see attached capture.png file). I simple setted the ThemeName property of the button, as you can see in capture2.png attached file.

Second, I tried to add a new theme to your ClassLibrary1 project, MyCustomTheme, I added it to the WindowFormsApplication7 but it doesn't appear as value on the ThemeName combo (as you can see in the capture3.png attached file).


Thank you.

0
Stefan
Telerik team
answered on 02 Nov 2012, 12:50 PM
Hello Giovanni,

It is my omission - I missed to add the code for overriding the ThemeName. Here is the full code for the theme component:
public class TelerikMetro : RadThemeComponentBase
  {
      static bool loaded = false;
 
      public TelerikMetro()
      {
          ThemeRepository.RegisterTheme(this);
      }
 
      public override void Load()
      {
          if (!loaded || IsDesignMode)
          {
              loaded = true;
              Assembly resourceAssembly = typeof(TelerikMetro).Assembly;
              LoadResource(resourceAssembly, "ClassLibrary1.TelerikMetro.tssp");
          }
      }
 
      public override string ThemeName
      {
          get
          {
              return "TelerikMetro";
          }
      }
  }

Let me know how this works for you.
 
Greetings,
Stefan
the Telerik team
Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
Themes and Visual Style Builder
Asked by
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Stefan
Telerik team
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or