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

How to dynamically apply a theme sitewide?

1 Answer 95 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Todd Davis
Top achievements
Rank 1
Todd Davis asked on 08 Jun 2010, 10:12 PM
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();
                    break;
                case "Office Black":
                    StyleManager.ApplicationTheme = new Office_BlackTheme();
                    break;
                case "Office Silver":
                    StyleManager.ApplicationTheme = new Office_SilverTheme();
                    break;
                case "Vista":
                    StyleManager.ApplicationTheme = new VistaTheme();
                    break;
                case "Summer":
                    StyleManager.ApplicationTheme = new SummerTheme();
                    break;
                case "Windows 7":
                    StyleManager.ApplicationTheme = new Windows7Theme();
                    break;
            }
        }
    }

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








1 Answer, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 09 Jun 2010, 09:20 AM
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.
Tags
General Discussions
Asked by
Todd Davis
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Share this question
or