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

Setting Multiple Custom Thems

2 Answers 72 Views
Navigation
This is a migrated thread and some comments may be shown as answers.
Narendra Joshi
Top achievements
Rank 1
Narendra Joshi asked on 21 Jun 2009, 10:34 PM
I am sure there must be some way to have multiple custom themes to be applied in one silverlight application.

Here is what I am trying to accomplish - 

1. Have one custom theme set at application level and 
2. Whereever required, set another theme for various controls depending on the requirement.
(Note: Custom themes are nothing but modified brushes of standard themes (Vista, OfficeBlack)

Currently I can set the custom theme to application and its working fine.

I have set the theme in App.xaml.cs as follows - 
themename = "OfficeBlack"
mainthemepath = "/<assembly name>;component/Themes/" + themename + "/generic.xaml"; 
submainthemepath = "/<assembly name>;component/Themes/Internal/" + themename + "/generic.xaml"; 
 
Theme customTheme = new Theme (new Uri(mainthemepath, UriKind.Relative)); 

Theme NewThemenew Theme (new Uri(submainthemepath, UriKind.Relative)); 

customTheme.IsApplicationTheme
 = true

 

I tried to apply another custom theme to a control as follows -  
StyleManager.SetTheme(<controlName>, App.NewTheme); 

But it seems its not getting applied. I am not sure whether this is suported and if yes how to set it.

Any help is highly appreciated. 

Thanks in Advance 

2 Answers, 1 is accepted

Sort by
0
Accepted
Boyan
Telerik team
answered on 24 Jun 2009, 02:51 PM
Hello Narendra Joshi,

This can be done, but you have to set  the individual control theme in the XAML. In fact, the way themes are implemented allows you to change the theme only once. The way you are trying to do this, you first change the theme of all the controls and you are not allowed for a second change. If set in XAML, the individual theme is applied first and then the application theme is applied to the other controls(that are not changed).

Of course you can always set each control's theme individually without setting theme for the whole application and this can be made entirely in the code but it is a little bit annoying if the controls are a lot.

The good news is that in Silverlight 3 it will be possible to change the Theme more than once due to a fix by Microsoft.

Hope this helps.

Sincerely yours,
Boyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Narendra Joshi
Top achievements
Rank 1
answered on 26 Jun 2009, 12:17 AM
Thanks for the tip !
Tags
Navigation
Asked by
Narendra Joshi
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Narendra Joshi
Top achievements
Rank 1
Share this question
or