This is a migrated thread and some comments may be shown as answers.
Changing Themes rumtime
8 Answers 179 Views
This is a migrated thread and some comments may be shown as answers.
Kamlesh
Top achievements
Rank 1
Kamlesh asked on 07 Dec 2008, 11:33 AM
Hi,

You have given the example which reloades the ThemeApplication. But in my case, application has several pages on a single page and also it has login page(maintaining the session). So it fails.

Is there any command from which i can  change the themes for the controls.
May be like RadControl.SetThemes(). If it is the command then how to use this.


Thanks
Kamlesh J

8 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 08 Dec 2008, 07:52 AM
Hello Kamlesh,

The property you need to set is:
public partial class App : Application
{
 public App()
 {
  InitializeComponent();

  Telerik.Windows.Controls.Theme.ApplicationTheme = "Telerik.Windows.Themes.Vista";
 }
...
}

This will set application-wide theme for ALL Telerik controls. Note that if you want to enable custom made application-wide theme you should put all XAML files in a folder named "themes" and also the resources for each control should be in separate XAML file, named after the control, e.g.
\
    themes\
        treeview.xaml
        combobox.xaml
        window.xaml
        ...

If a control is unable to find a needed resource in your theme XAML it will automatically use the same resource from its default theme.

I hope this helps.

Best wishes,
Valeri Hristov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
SSN
Top achievements
Rank 1
answered on 12 Dec 2008, 03:02 PM
Hi,
I do have the same problem, I have set in App.xaml.cs

 

 

 

public

void RefreshTheme()

 

 

{

if

(ThemeCode == string.Empty)

 

        Telerik.Windows.Controls.

Theme.ApplicationTheme = "Telerik.Windows.Themes.Default";

 

 

else

 

        Telerik.Windows.Controls.

Theme.ApplicationTheme = ThemeCode;

 

this

.RootVisual = new Page1();

 

 

InitializeComponent();
}

public
string ThemeCode

 

{

 

  get

 

 

 

      {

return this.m_ThemeCode;}

 

 

  set

 

 

 

      {

this.m_ThemeCode = value;}
 }

But still it takes the default and not refreshing the set property from my page1 when calling RefreshPage().
Is there any other reset call I need to make, I believe once a new theme is set to ApplicationTheme an event would fire to apply the new change.

Please help.

Thanks,
S.Murali.

 

0
Valeri Hristov
Telerik team
answered on 12 Dec 2008, 05:59 PM
Hi SSN,

I am not sure that I completely understand your scenario, but I should note that the themes in Silverlight work only once, since they are based on styles, which can be applied only once. If you are trying to apply a new theme runtime, once the default (or any other) theme was already applied, nothing will happen and this is the expected behavior. In other words, setting ApplicationTheme will work only before the controls are loaded, and only once.

Greetings,
Valeri Hristov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
SSN
Top achievements
Rank 1
answered on 15 Dec 2008, 04:52 PM
Hi Valeri,

Thanks for your clarification, my requirement was to provide a drop down of available themes and on selecting a theme apply the colors for all the controls.

Thanks,
S.Murali.
0
Valeri Hristov
Telerik team
answered on 15 Dec 2008, 05:05 PM
Hello SSN,

To do that you will have to reload the entire HTML page when the dropdown selection changes, but this will reset the Silverlight application, which usually brings more problems with persisting state, etc. If you want to try it, I could prepare a simple example that demonstrates how to reload the page.

All the best,
Valeri Hristov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Zero Gravity Chimp
Top achievements
Rank 2
answered on 10 Jun 2010, 06:39 AM
Does this mean that it can't be done without the complications described above?

I'm trying to do this with gauge with silverlgiht controls Q1/10 SP2.

This is a common requirement, if it is possible I think you should link the method here.

Help does not have anything on the topic. I have also downloaded the sample app that resets the rootvisual to change the theme but i have a dashboard application and i need a simple dropdown to change the themes. Any advice?
0
Pavel Pavlov
Telerik team
answered on 10 Jun 2010, 08:12 AM
Hi guys ,

In our upcoming beta ( in a few days)  there is something that might be usefull for this scenario.We are introducing a new theme for our Silverlight controls - the Transparent theme.

It is designed in such way that changing just the background  of the application , would give all the controls a new color scheme .

You may see it in action  in this blog post. There is a small color swatch in the demo app there , you may click on it to see how you can rapidly switch different colors for the controls by just switching the background.

Hope this is helpful .

Best wishes,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Zero Gravity Chimp
Top achievements
Rank 2
answered on 10 Jun 2010, 08:22 AM
Great feature, new themes will always go down well. It is still a big question though how i could change to this theme at runtime. One more great theme I cant add to a drop-down list for the user?
Asked by
Kamlesh
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
SSN
Top achievements
Rank 1
Zero Gravity Chimp
Top achievements
Rank 2
Pavel Pavlov
Telerik team
Share this question
or