/// <summary> /// Removes the theme. /// </summary> /// <param name="source">The source.</param> /// <param name="theme">The theme.</param> public void RemoveTheme(ResourceDictionary source, Theme theme) { source.Guard("source"); theme.Guard("theme"); lock (LoadedThemes) { ResourceDictionary dict; if (!LoadedThemes.TryGetValue(theme.UniqueId, out dict)) { return; } source.MergedDictionaries.Remove(dict); } }
/// <summary> /// Applies the theme. /// </summary> /// <param name="target"></param> /// <param name="theme">The theme.</param> public void ApplyTheme(ResourceDictionary target, Theme theme) { target.Guard("target"); theme.Guard("theme"); lock (LoadedThemes) { ResourceDictionary dict; RemoveTheme(target, theme); if (!LoadedThemes.TryGetValue(theme.UniqueId, out dict)) { var resource = theme.GetResourceLocation(); var sourceAssembly = theme.GetType().Assembly; dict = new ResourceDictionary { Source = RuntimeHelper.MakePackUri(sourceAssembly, resource) }; } target.MergedDictionaries.Add(dict); } }