This is a migrated thread and some comments may be shown as answers.
How to change theme in silverlight at runtime
6 Answers 197 Views
This is a migrated thread and some comments may be shown as answers.
Jaroslav Půbal
Top achievements
Rank 1
Jaroslav Půbal asked on 21 Apr 2010, 11:35 PM
I really search this forum and documentation long time and nothing found. :-(

Is it possible in silverlight for telerik components ?

6 Answers, 1 is accepted

Sort by
0
Jaroslav Půbal
Top achievements
Rank 1
answered on 22 Apr 2010, 09:44 PM
0
Jaroslav Půbal
Top achievements
Rank 1
answered on 23 Apr 2010, 09:39 AM
Is there better way for repaint complete visual tree ?
The way described in link above is possibly destrutive to references if using "Prism regions" or MEF.

0
Accepted
Valeri Hristov
Telerik team
answered on 26 Apr 2010, 04:38 PM
Hello Jaroslav,

The so called application themes replace the default styles of the controls in Generic.xaml. When you change the application theme, the controls do not update their default styles, hence you need to recreate the whole visual tree.

Instead of setting application theme you could use the telerik:StyleManager.Theme attached property on every Telerik control (and most of the standard Silverlight controls) to specify a theme. I suppose that the best would be to provide a Theme property in your view models and bind the attached property to the Theme property - when the Theme is changed, the attached property will update all controls.

Best wishes,
Valeri Hristov
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
vm0411
Top achievements
Rank 1
answered on 27 Jan 2011, 07:46 AM
I tried the method you described, which I nicked from the sample called "RuntimeThemeChange" somewhere on this forum.
So it goes like :

<TextBlock telerik:StyleManager.Theme="{Binding CurrentTheme.Theme}">My Text Box:</TextBlock>

Works OK


I need to add some controls (RadioButtons) in the code-behind as:

RadioButton myRadioButton = new RadioButton();
//need some theme binding here
this.MyPanel.Children.Add(myRadioButton);


How to bind the theme is this case?

0
Valeri Hristov
Telerik team
answered on 27 Jan 2011, 09:06 AM
You can use something like:

var radioButton = new RadioButton();
radioButton.SetBinding(StyleManager.Theme, new Binding("CurrentTheme.Theme"));
...
this.MyPanel.Children.Add(radioButton);

Best wishes,
Valeri Hristov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
vm0411
Top achievements
Rank 1
answered on 28 Jan 2011, 12:00 AM
Thanks Valeri. Works like a charm
Asked by
Jaroslav Půbal
Top achievements
Rank 1
Answers by
Jaroslav Půbal
Top achievements
Rank 1
Valeri Hristov
Telerik team
vm0411
Top achievements
Rank 1
Share this question
or