Esempio n. 1
0
        private void SwitchTheme(ThemeTypeEnum themeType)
        {
            // global Referenz auf unsere App holen
            var app = Application.Current as App;

            // globalen resource dic leeren
            app.Resources.Clear();
            // auch die rein-gemerged-en dics löschen
            app.Resources.MergedDictionaries.Clear();

            // no style -> no action
            if (themeType == ThemeTypeEnum.None)
            {
                return;
            }

            var uri   = Themes.GetThemeUri(themeType);
            var theme = Application.LoadComponent(uri) as ResourceDictionary;

            // nun unser Theme wieder laden
            app.Resources.MergedDictionaries.Add(theme);
        }
Esempio n. 2
0
 public static Uri GetThemeUri(ThemeTypeEnum theme)
 {
     return(new Uri($"{Folder}/{theme}.xaml", UriKind.Relative));
 }
Esempio n. 3
0
 /// <summary>
 /// 获取枚举的对应的字符串值
 /// </summary>
 /// <returns></returns>
 public static int GetIntValue(this ThemeTypeEnum DataViewType)
 {
     return((int)DataViewType);
 }