/// <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; var pack = RuntimeHelper.MakePackUri(sourceAssembly, resource); dict = new ResourceDictionary { Source = pack }; } target.MergedDictionaries.Add(dict); } }