Setting Multiple Custom Thems

3 posts, 1 answers
  1. Narendra Joshi
    Narendra Joshi avatar
    4 posts
    Member since:
    Jun 2009

    Posted 21 Jun 2009 Link to this post

    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)); 

     = 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. Answer
    Boyan avatar
    758 posts

    Posted 24 Jun 2009 Link to this post

    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,
    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.
  3. Narendra Joshi
    Narendra Joshi avatar
    4 posts
    Member since:
    Jun 2009

    Posted 25 Jun 2009 Link to this post

    Thanks for the tip !
Back to Top