How to dynamically apply a theme sitewide?

2 posts, 0 answers
  1. Todd Davis
    Todd Davis avatar
    36 posts
    Member since:
    Aug 2009

    Posted 08 Jun 2010 Link to this post

    I saw a demo on how to dynamically change a single control bound to a combobox, something like this:

    telerik:StyleManager.Theme="{Binding SelectedValue, ElementName=themesBox}

    That's all well and good, but I want to change the theme site-wide via the combobox. So I tried doing this in the MasterPage, again, bound to the ComboBox:

            private void Theme_SelectionChanged(object sender, SelectionChangedEventArgs e)
                switch (Theme.SelectedItem.ToString())
                    case "Office Blue":
                        StyleManager.ApplicationTheme = new Office_BlueTheme();
                    case "Office Black":
                        StyleManager.ApplicationTheme = new Office_BlackTheme();
                    case "Office Silver":
                        StyleManager.ApplicationTheme = new Office_SilverTheme();
                    case "Vista":
                        StyleManager.ApplicationTheme = new VistaTheme();
                    case "Summer":
                        StyleManager.ApplicationTheme = new SummerTheme();
                    case "Windows 7":
                        StyleManager.ApplicationTheme = new Windows7Theme();

    However, nothing changes when select a new setting. Is there something else I need to call in order to make the change "take"?

  2. Yavor Georgiev
    Yavor Georgiev avatar
    982 posts

    Posted 09 Jun 2010 Link to this post

    Hello Todd Davis,

     Regrettably, Silverlight does not allow us to do that. You will have to bind each control that you want to apply a  theme to like so:

    <telerik:RadButton telerik:StyleManager.Theme="{Binding SelectedValue, ElementName=themesBox}">Click me!</telerik:RadButton>

    That is why the only place where you can set the ApplicationTheme in code-behind for it to have any effect is before InitializeComponent() is called and the controls are created.

    All the best,
    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.
Back to Top