This question is locked. New answers and comments are not allowed.
I have created a RadComboBox to select Theme.
<telerik:RadComboBox Width="100" Height="30" Margin="20,5" VerticalAlignment="Bottom" SelectionChanged="RadComboBox_SelectionChanged"> <telerik:RadComboBoxItem Content="Expression_Dark" /> <telerik:RadComboBoxItem Content="Office_Black" /> <telerik:RadComboBoxItem Content="Office_Blue" /> <telerik:RadComboBoxItem Content="Office_Silver" /> <telerik:RadComboBoxItem Content="Summer" /> <telerik:RadComboBoxItem Content="Transparent" /> <telerik:RadComboBoxItem Content="Vista" /> <telerik:RadComboBoxItem Content="Windows7" /> </telerik:RadComboBox>And my code in MainPage.xaml.cs:
public MainPage(){ StyleManager.ApplicationTheme = new Windows7Theme(); InitializeComponent(); }private MainPage(int index) //overload of Mainpage(){ switch (index) { case 0: StyleManager.ApplicationTheme = new Expression_DarkTheme(); break; case 1: StyleManager.ApplicationTheme = new Office_BlackTheme(); break; case 2: StyleManager.ApplicationTheme = new Office_BlueTheme(); break; case 3: StyleManager.ApplicationTheme = new Office_SilverTheme(); break; case 4: StyleManager.ApplicationTheme = new SummerTheme(); break; case 5: StyleManager.ApplicationTheme = new TransparentTheme(); break; case 6: StyleManager.ApplicationTheme = new VistaTheme(); break; case 7: StyleManager.ApplicationTheme = new Windows7Theme(); break; } InitializeComponent(); }private void RadComboBox_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e){ RadComboBox comboBox = sender as RadComboBox; int index = comboBox.SelectedIndex; this.RootVisual = new MainPage(index);}But it seems that this could not work right.
So, what's wrong with my code? And what's the right way to set theme at runtime?
Thanks, any help will be appreciated.
Yue