Your documentation is prone to a known WPF bug:
http://www.telerik.com/help/wpf/styling-apperance-themes-runtime.html
In my WPF 4.0 project, your code makes all my controls disappear. Apparently, there is a known bug in the MergedDictionaries.Clear() method, as pointed out here:
http://social.msdn.microsoft.com/Forums/en/wpf/thread/dd061aa4-0151-4122-ab4d-25ae6b6e7c94
This did the trick for me:
// WORKAROUND: Application.Current.Resources.MergedDictionaries.Clear();
for (int i = Application.Current.Resources.MergedDictionaries.Count - 1; i >= 0; --i)
Application.Current.Resources.MergedDictionaries.RemoveAt(i);
http://www.telerik.com/help/wpf/styling-apperance-themes-runtime.html
In my WPF 4.0 project, your code makes all my controls disappear. Apparently, there is a known bug in the MergedDictionaries.Clear() method, as pointed out here:
http://social.msdn.microsoft.com/Forums/en/wpf/thread/dd061aa4-0151-4122-ab4d-25ae6b6e7c94
This did the trick for me:
// WORKAROUND: Application.Current.Resources.MergedDictionaries.Clear();
for (int i = Application.Current.Resources.MergedDictionaries.Count - 1; i >= 0; --i)
Application.Current.Resources.MergedDictionaries.RemoveAt(i);