public static void SetTheme(ApplicationTheme theme) { if (ApplicationData.Current.LocalSettings.Values.ContainsKey(ThemeTypeKey)) { ApplicationData.Current.LocalSettings.Values[ThemeTypeKey] = theme.ToString(); } else { ApplicationData.Current.LocalSettings.Values.Add(ThemeTypeKey, theme.ToString()); } }
public static void UpdateAppTheme(ApplicationTheme theme) { ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; localSettings.Values.TryGetValue(_themeKey, out var previousTheme); if ((string)previousTheme == theme.ToString()) { return; } localSettings.Values[_themeKey] = theme.ToString(); App.UpdateAppTheme(); }
public static string ToThemeName(this ApplicationTheme theme) { switch (theme) { // This could probably all be done via Enum.ToString(), // but if, for some reason, it gets refactored, I want to ensure backwards // compatibility. case ApplicationTheme.Light: return("Light"); case ApplicationTheme.Dark: return("Dark"); default: return(theme.ToString()); } }
private static ElementTheme LoadThemeFromSettingsAsync(ApplicationTheme requestedTheme) { var settingsAdapter = new SettingsAdapter(); var settingsFacade = new SettingsFacade(settingsAdapter); ElementTheme cacheTheme = ElementTheme.Default; string themeName = settingsAdapter.GetValue(SETTINGS_KEY, string.Empty); if (!string.IsNullOrEmpty(themeName)) { Enum.TryParse(themeName, out cacheTheme); } if (cacheTheme == ElementTheme.Default && settingsFacade.Theme.ToString() != requestedTheme.ToString()) { ThemeManager.ChangeTheme(Enum.Parse <AppTheme>(requestedTheme.ToString())); } return(cacheTheme); }
public void SetTheme(ApplicationTheme theme) { _settingsService.SetSetting("Theme", theme.ToString()); }
internal void UpdateSkin(ApplicationTheme theme) { ThemeManager.Current.ApplicationTheme = theme; var demoResources = new ResourceDictionary { Source = PackUriHelper.GetAbsoluteUri("HandyControlDemo", $"/Resources/Themes/Basic/Colors/{theme.ToString()}.xaml") }; Resources.MergedDictionaries[0].MergedDictionaries.InsertOrReplace(1, demoResources); }