Incorrect documentation for theme switching

1 posts, 0 answers
  1. Kristoffer
    Kristoffer avatar
    30 posts
    Member since:
    Oct 2012

    Posted 11 Dec 2012 Link to this post

    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);
Back to Top