11 Answers, 1 is accepted
0
Kennet
Top achievements
Rank 2
answered on 25 Nov 2009, 09:46 PM
ok so I found this that works
but how do I change in runtime when app is running, just runing this don't work.
public partial class Window1 : Window |
{ |
public Window1() |
{ |
StyleManager.ApplicationTheme = new VistaTheme(); |
InitializeComponent(); |
} |
} |
but how do I change in runtime when app is running, just runing this don't work.
StyleManager.ApplicationTheme = new Windows7Theme(); |
0
Hi Kennet,
The application themes work only for newly instantiated controls, hence we recommend setting ApplicationTheme before the call to InitializeComponent(). You could workaround this limitation by recreating the page content when changing the theme (we do the same in our online examples).
Regards,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The application themes work only for newly instantiated controls, hence we recommend setting ApplicationTheme before the call to InitializeComponent(). You could workaround this limitation by recreating the page content when changing the theme (we do the same in our online examples).
Regards,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kennet
Top achievements
Rank 2
answered on 30 Nov 2009, 07:03 PM
Hi Valeri,
Thanks, but I can't find in your example code how you change Theme in runtime. Please post C# code.
Thanks, but I can't find in your example code how you change Theme in runtime. Please post C# code.
0
Hi Kennet,
Please, find attached a simple application that changes application themes at runtime.
Greetings,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Please, find attached a simple application that changes application themes at runtime.
Greetings,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kennet
Top achievements
Rank 2
answered on 04 Dec 2009, 01:13 PM
Thanks Valeri,
But I need code for WPF, not Silverlight. I tried but can't use the example in WPF.
But I need code for WPF, not Silverlight. I tried but can't use the example in WPF.
0
Hi Kennet,
I apologize for that, I overlooked the forum name. I will send you another sample in 20minutes.
Regards,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I apologize for that, I overlooked the forum name. I will send you another sample in 20minutes.
Regards,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Hi Kennet,
Here is the promised application.
Best wishes,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Here is the promised application.
Best wishes,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kennet
Top achievements
Rank 2
answered on 04 Dec 2009, 01:58 PM
Thanks, but for now I can't use that method since my app only have one window (sure I could but all in a usercontrol, but don't wanna do that). Is there another way to do this?
0
Hi Kennet,
Unfortunately this is the only way to set an application theme with Telerik StyleManager and change it at runtime. You could try binding the StyleManager.Theme attached property on every Telerik control to a property that contains the currently selected theme. However, this would require more work, especially if you have lots of controls.
All the best,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Unfortunately this is the only way to set an application theme with Telerik StyleManager and change it at runtime. You could try binding the StyleManager.Theme attached property on every Telerik control to a property that contains the currently selected theme. However, this would require more work, especially if you have lots of controls.
All the best,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Garry Clark
Top achievements
Rank 1
answered on 16 Jun 2010, 06:43 PM
Kennet,
I know this is a very old post, but I thought I would respond anyways. Basically the way I am doing this is by basically doing what Valeri said in her last post and I bind to the StyleManager in the Xaml everytime I define a Telerik control as such.
and then I have an User Setting called CurrentTheme, which gets updated when a user chooses a new theme from a dropdown list.
The ItemSource is tied to another User Setting, but you could tie it to anything. I keep meaning to rework it to pull from something like this:
but have been to lazy to do so.
Here is the other related code just in case.
User Settings
Resource Dictionary
Anyhow hope this helps you or someone in someway!
I know this is a very old post, but I thought I would respond anyways. Basically the way I am doing this is by basically doing what Valeri said in her last post and I bind to the StyleManager in the Xaml everytime I define a Telerik control as such.
<telerik:RadButton Name="btn" Width="110" telerik:StyleManager.Theme="{Binding Source={StaticResource settings}, Path=Default.CurrentTheme}"/> |
<telerikInput:RadComboBox x:Name="comboTheme" DataContext="{x:Static settings:Settings.Default}" |
SelectedItem="{Binding CurrentTheme, Mode=TwoWay}" ItemsSource="{Binding Themes}" |
telerik:StyleManager.Theme="{Binding Source={StaticResource settings}, Path=Default.CurrentTheme}"/> |
ReadOnlyCollection<string> themes = ThemeManager.StandardThemeNames; |
Here is the other related code just in case.
User Settings
<userSettings> |
<EliteExtender.Infrastructure.Properties.Settings> |
<setting name="Themes" serializeAs="Xml"> |
<value> |
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
<string>Office_Blue</string> |
<string>Office_Black</string> |
<string>Office_Silver</string> |
<string>Summer</string> |
<string>Vista</string> |
<string>Windows7</string> |
</ArrayOfString> |
</value> |
</setting> |
<setting name="CurrentTheme" serializeAs="String"> |
<value>Windows7</value> |
</setting> |
</EliteExtender.Infrastructure.Properties.Settings> |
</userSettings> |
<ResourceDictionary |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:settings="clr-namespace:EliteExtender.Infrastructure.Properties"> |
<ResourceDictionary.MergedDictionaries> |
<ResourceDictionary> |
<settings:Settings x:Key="settings" /> |
</ResourceDictionary> |
</ResourceDictionary.MergedDictionaries> |
</ResourceDictionary> |
Anyhow hope this helps you or someone in someway!
0
Waleed Seada
Top achievements
Rank 2
answered on 17 Jan 2011, 04:11 PM
Hello there,
Can anyone tell me how to implement this in a MVVM approach using Q2 2010.
Best regards
Waleed
Can anyone tell me how to implement this in a MVVM approach using Q2 2010.
Best regards
Waleed