I have successfully developed a number of custom themes which are being applied to Telerik controls at the application level. I understand that to assign the theme to standard silverlight controls, I have to use the telerik:StyleManager.Theme on individual controls. The theme is being selected at runtime so I need to dynamically allocate the them to the standard controls in XAML. I am thinking it would be something like:
<TextBlock Text="Hello" Grid.Row="1" telerik:StyleManager.Theme="{StyleManager.ApplicationTheme}" />
Can someone point me in the right direction?
Regards
Alan
4 Answers, 1 is accepted
It would be great if I could set each control directly to StyleManager.ApplicationTheme though so if anyone has some thoughts it would be greatly appreciated
Alan
The Telerik themes are designed to work mainly with our RadControls and some native Silverlight controls. Some of them are TextBox, ListBox, ScrollBar, CheckBox, Button etc. Our theming mechanism cannot cover the full control list included either in Silverlight or in WPF. In our online documenation you may find a very useful information about the theming mechanism that we offer and how it can be applied to different RadControls.
If you need any additional information, please let me know.
Vanya Pavlova
the Telerik team
Thanks for your reply. I had already read all the documentation and have custom themes working (sortof). My question was more about what is the best way to assign a theme to a standard silverlight control where the theme isnt known until runtime. i.e I would like to do something like <TextBlock Text="Hello" Grid.Row="1" telerik:StyleManager.Theme="{StyleManager.ApplicationTheme}" />. Do you have any suggestions?
Also, I can only get my theme working using [ThemeLocation(ThemeLocation.External)] rather than [ThemeLocation(ThemeLocation.BuiltIn)]. How do I decide which attribute to use?
Regards
Alan
When you change the application theme, the controls do not update their default styles as you need to recreate the whole visual tree. You may switch between the themes at runtime, but you will need to reload the whole view. On the other hand, instead of setting application theme, you could use the telerik:StyleManager.Theme attached property on every Telerik control (and some of the standard Silverlight controls) to specify a theme.
I have prepared an example for you that demonstrates how to dynamically change the theme using RadComboBox.
Regarding your second question: The ThemeLocation is an enumeration which is used to distinguish between built-in and custom themes with members Built-In and External.
The Built-In attrubute represents a theme developed by Telerik and hosted in the control assembly.
The External attribute represents a theme hosted in an external assembly.
You may see at the following online help article "Creating a Custom Theme Project - Using the Telerik Approach" that is defined a non-existent file Generic.xaml. Thus when the Telerik StyleManager uses a Theme class with ThemeLocation=BuiltIn, it ignores the path to the XAML file and replaces it with ";component/themes/[control assembly].xaml". In this example the Telerik StyleManager will replace the
provided path with "/MyTheme;component/Themes/Telerik.Windows.Controls.xaml".
Vanya Pavlova
the Telerik team