Example #1
0
        public static void LoadSettings()
        {
            // Load all available themes
            Themes = new List<Theme>();
            var blue = new ResourceDictionary { Source = new Uri("ms-appx:///Themes/Blue.xaml") };
            var blueTheme = new Theme { Resource = blue };
            var black = new ResourceDictionary { Source = new Uri("ms-appx:///Themes/Black.xaml") };
            var blackTheme = new Theme { Resource = black };
            var red = new ResourceDictionary { Source = new Uri("ms-appx:///Themes/Red.xaml") };
            var redTheme = new Theme { Resource = red };
            Themes.Add(blueTheme);
            Themes.Add(blackTheme);
            Themes.Add(redTheme);

            // Load Theme
            var setTheme = new Theme();
            var localSettings = ApplicationData.Current.LocalSettings;
            var theme = localSettings.Values["Theme"];
            if (theme == null)
            {
                // Theme not set so default to Black
                var resource = new ResourceDictionary { Source = new System.Uri("ms-appx:///Themes/Black.xaml") };
                setTheme.Resource = resource;
            }

            else
            {
                var resource = new ResourceDictionary { Source = new System.Uri(theme.ToString()) };
                setTheme.Resource = resource;
            }
            Theme = setTheme;
        }
        public void ChangeTheme(Theme theme)
        {
            //Prompt User to restart


            //var loadedResources = App.Current.Resources.MergedDictionaries.ToList();
            //foreach (var resource in loadedResources)
            //{
            //    if (resource.Source.ToString().Contains("Theme"))
            //    {
            //        App.Current.Resources.MergedDictionaries.Remove(resource);
            //    }
            //}
            //App.Current.Resources.MergedDictionaries.Add(theme.Resource);
            BookieSettings.Theme = Theme;
           // Theme = Themes.FirstOrDefault(x => x.Resource.Source == BookieSettings.Theme.Resource.Source);

            BookieSettings.SaveSettings();
            if (Theme.Name != CurrentTheme.Name)
            {
                ShellViewModel.ShowMessage("Restart required to change theme", null);

            }


        }