public void Update(bool systemTheme = false) { try { // Because of Compact, UpdateSource may be executed twice, but there is a bug in XAML and manually clear theme dictionaries here: // Prior to RS5, when ResourceDictionary.Source property is changed, XAML forgot to clear ThemeDictionaries. ThemeDictionaries.Clear(); MergedDictionaries.Clear(); MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("ms-appx:///Themes/" + (systemTheme ? "ThemeSystem" : "ThemeGreen") + ".xaml") }); } catch { } }
public void Update() { // Because of Compact, UpdateSource may be executed twice, but there is a bug in XAML and manually clear theme dictionaries here: // Prior to RS5, when ResourceDictionary.Source property is changed, XAML forgot to clear ThemeDictionaries. string deviceFamilyVersion = AnalyticsInfo.VersionInfo.DeviceFamilyVersion; ulong version = ulong.Parse(deviceFamilyVersion); ulong build = (version & 0x00000000FFFF0000L) >> 16; if (build < 17763) { ThemeDictionaries.Clear(); } MergedDictionaries.Clear(); MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("ms-appx:///Themes/ThemeGreen.xaml") }); }
public void Update(ThemeCustomInfo custom) { if (custom == null) { Update(SettingsService.Current.Appearance.RequestedTheme); return; } try { // Because of Compact, UpdateSource may be executed twice, but there is a bug in XAML and manually clear theme dictionaries here: // Prior to RS5, when ResourceDictionary.Source property is changed, XAML forgot to clear ThemeDictionaries. ThemeDictionaries.Clear(); MergedDictionaries.Clear(); MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("ms-appx:///Themes/ThemeGreen.xaml") }); var dict = new ResourceDictionary(); foreach (var item in custom.Values) { if (item.Key.EndsWith("Brush")) { dict[item.Key] = new SolidColorBrush((Color)item.Value); } else if (item.Key.EndsWith("Color")) { dict[item.Key] = (Color)item.Value; } } MergedDictionaries[0].MergedDictionaries.Clear(); MergedDictionaries[0].MergedDictionaries.Add(dict); if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { TLWindowContext.GetForCurrentView().UpdateTitleBar(); } } catch { } }
private void Update(IDictionary <string, Color> values) { try { // Because of Compact, UpdateSource may be executed twice, but there is a bug in XAML and manually clear theme dictionaries here: // Prior to RS5, when ResourceDictionary.Source property is changed, XAML forgot to clear ThemeDictionaries. ThemeDictionaries.Clear(); MergedDictionaries.Clear(); MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("ms-appx:///Themes/ThemeGreen.xaml") }); var dict = new ResourceDictionary(); foreach (var item in values) { if (item.Key.EndsWith("Brush")) { dict[item.Key] = new SolidColorBrush((Color)item.Value); } else if (item.Key.EndsWith("Color")) { dict[item.Key] = (Color)item.Value; } } MergedDictionaries[0].MergedDictionaries.Clear(); MergedDictionaries[0].MergedDictionaries.Add(dict); if (ApiInfo.HasStatusBar) { TLWindowContext.GetForCurrentView()?.UpdateTitleBar(); } } catch { } }
public void Update(ElementTheme flags) { try { // Because of Compact, UpdateSource may be executed twice, but there is a bug in XAML and manually clear theme dictionaries here: // Prior to RS5, when ResourceDictionary.Source property is changed, XAML forgot to clear ThemeDictionaries. ThemeDictionaries.Clear(); MergedDictionaries.Clear(); if (flags == ElementTheme.Default) { MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("ms-appx:///Themes/ThemeSystem.xaml") }); } else { MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("ms-appx:///Themes/ThemeGreen.xaml") }); } } catch { } }