WPF change theme/style at runtime

Hi,

Here is an example of how to change in a WPF application the theme at runtime.

WPF change Theme

As you can see  when we cahnge the selected combobox item it automatically changes the theme, which actually clears the application’s resources and loads adifferent xaml file with resources and added this to the SelectionChanged event.

 private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ResourceDictionary skin = new ResourceDictionary();
skin.Source = new Uri(@”" + cbxThemes.SelectedValue.ToString() + “.xaml”, UriKind.Relative);
Application.Current.Resources.MergedDictionaries.Clear();
Application.Current.Resources.MergedDictionaries.Add(skin);
}

Here you can download the sample files.

WPF change Theme sample

WPF TreeView (2Advance style) done in XAML

Hi,

Sorry for not posting any news tutorials, I’ve been busy with trying to add a news section to my site and now i’m currently working and a Silverlight version of my site.

As you can see in the picture below I’ve tried to  reproduce the Treeview from 2advanced.com website:

previewtree

Here is the code sample if you have any question please ask them and i will try to respond to them.