Change Theme Dynamically

10 posts, 1 answers
  1. Rahul Gupta
    Rahul Gupta avatar
    10 posts
    Member since:
    May 2010

    Posted 27 May 2010 Link to this post

    How can I change theme dynamically using RadControls.
    I already visited this link:
    http://www.telerik.com/community/forums/silverlight/general-discussions/how-do-i-apply-a-theme.aspx
    but not able to get any solution. Selecting Theme from dropdown Combobox I want to change Theme. How can I acheive that. Till now I have not yet got a single Solution for my problem from the Telerik team. Please help me to solve this issue.
  2. Answer
    Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 27 May 2010 Link to this post

    Hello Rahul Gupta,

     Please find attached a solution demonstrating how to change the theme of a telerik control from a ComboBox.

    Regards,
    Yavor Georgiev
    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.
  3. DevCraft banner
  4. Rahul Gupta
    Rahul Gupta avatar
    10 posts
    Member since:
    May 2010

    Posted 28 May 2010 Link to this post

    Thank you Telerik Team for you Support.
  5. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 13 Sep 2010 Link to this post

    This sample is setting the control in xaml.  How do you do it from code behind.  My scenario is that I've created a RadGridView dynamically and want to set the theme from code behind.
  6. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 13 Sep 2010 Link to this post

    Figured it out:

    StyleManager.SetTheme(MyRadControl, new Telerik.Windows.Controls.Office_SilverTheme());
     

     

     

     

     

     

     

     

  7. Pic Micro
    Pic Micro avatar
    6 posts
    Member since:
    Mar 2010

    Posted 16 Sep 2010 Link to this post

    Hello, Is there way to load a theme from an URL. I'm asking that since I have done some things with Flex and that's one of the things I missed from Flex.

    Thx
  8. George
    Admin
    George avatar
    1332 posts

    Posted 22 Sep 2010 Link to this post

    Hi Pic,

    Our themes can be downloaded dynamically if this suits your needs. I am not sure I understand you question. Could you please give us more detailed information? If you tell us what is your scenario it would be very helpful. 

    Regards,
    George
    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
  9. CyclingFoodmanPA
    CyclingFoodmanPA avatar
    6 posts
    Member since:
    Dec 2010

    Posted 04 Mar 2011 Link to this post

    Hello Yavor,

    Great example.  I am wondering how to change themes dynamically for an entire application.  This particular example changes the theme for the grid which is great, but how do you change the theme for an application using the RadControls.  There is an example at: http://weblogs.asp.net/lduveau/archive/2010/05/31/dynamically-apply-and-change-theme-with-the-silverlight-toolkit.aspx that allows you to change the theme for the entire application using the SL toolkit.

    Could you or someone put up an example on how to do this with the telerik controls.  I think it is similar to the one above, but I am missing something and cannot get it to work.  I know I am close but I know as soon as I see the correct solution I will probably be mad at myself because I am close.

    Thanks for developing great controls.

    Keith

    P.S. I am using the latest Silverlight RadControls (build from Q4 2010).
  10. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 05 Mar 2011 Link to this post

    Hello Keith,

     The theming mechanism for our Silverlight controls suite is a bit different from the one in the Silverlight Toolkit that Microsoft provides.

     In your UserControl, create a dependency property called CurrentTheme, of type Telerik.Windows.Controls.Theme. Give it a default value of, say, a new instance of the Office_BlackTheme class.

     Then, in the XAML of your UserControl, bind the telerik:StyleManager.Theme attached property of every telerik control to the CurrentTheme property of the UserControl. If you change the value of the CurrentTheme property, all the controls that are bound to it should change as well.

     Unfortunately there is no easy or surefire way to achieve this. We are constantly looking forward to improving our theming mechanism, but keeping it backwards-compatible and consistent across our WPF and Silverlight suites is no easy task. Hopefully we will be able to implement on-the-fly changing of the current application theme in our StyleManager very soon.

    Greetings,
    Yavor Georgiev
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  11. John
    John avatar
    3 posts
    Member since:
    Dec 2011

    Posted 14 Aug 2012 Link to this post

    The above code approach works as per this video .. however the control that I am using to change the theme is a RadComboBox on the selection change event. This works except it does not update the RadComboBox so I then added a StyleManager for the RadComboBox itself, and even though it does change the Theme, I also get an null ref exception. It appears that you can't change a theme within a SelectionChanged event handler else you will throw an exception.  As a simple work-around I created a simple Timer that fires 20 milliseconds post the selection change event, and in which where I apply the newly changed Theme. This works but I do not like this approach.  Is there a better control event that I can use to set the Theme of the control that is altering the Theme?
Back to Top
DevCraft banner