Esempio n. 1
0
        private void ToggleButton_Click(object sender, RoutedEventArgs e)
        {
            // Set theme for window root.
            if (global::Windows.UI.Xaml.Window.Current.Content is FrameworkElement root)
            {
                switch (root.ActualTheme)
                {
                case ElementTheme.Default:
                    if (SystemThemeHelper.GetSystemApplicationTheme() == ApplicationTheme.Dark)
                    {
                        root.RequestedTheme = ElementTheme.Light;
                    }
                    else
                    {
                        root.RequestedTheme = ElementTheme.Dark;
                    }
                    break;

                case ElementTheme.Light:
                    root.RequestedTheme = ElementTheme.Dark;
                    break;

                case ElementTheme.Dark:
                    root.RequestedTheme = ElementTheme.Light;
                    break;
                }
            }
        }
Esempio n. 2
0
        private void ToggleButton_Click(object sender, RoutedEventArgs e)
        {
            // Set theme for window root.
            if (global::Windows.UI.Xaml.Window.Current.Content is FrameworkElement root)
            {
                switch (root.ActualTheme)
                {
                case ElementTheme.Default:
                    if (SystemThemeHelper.GetSystemApplicationTheme() == ApplicationTheme.Dark)
                    {
                        root.RequestedTheme = ElementTheme.Light;
                    }
                    else
                    {
                        root.RequestedTheme = ElementTheme.Dark;
                    }
                    break;

                case ElementTheme.Light:
                    root.RequestedTheme = ElementTheme.Dark;
                    break;

                case ElementTheme.Dark:
                    root.RequestedTheme = ElementTheme.Light;
                    break;
                }

                if (NavigationViewControl.PaneDisplayMode == MUXC.NavigationViewPaneDisplayMode.LeftMinimal)
                {
                    // Close navigation view when changing the theme
                    // to allow the user to see the difference between the themes.
                    NavigationViewControl.IsPaneOpen = false;
                }
            }
        }
Esempio n. 3
0
        public static void SetSystemTheme(string name)
        {
            var    a         = name.Split('.');
            string themename = a[0];
            string colorname = "NormalColor";

            if (a.Length >= 2)
            {
                colorname = a[1];
            }
            if (themename.ToLower() == "classic")
            {
                colorname = string.Empty;
            }
            SystemThemeHelper.SetTheme(themename, colorname);
        }
        public void SetTheme(Models.Domain.ApplicationTheme applicationTheme)
        {
#if WINDOWS_UWP
            if (applicationTheme == Models.Domain.ApplicationTheme.Default)
            {
                applicationTheme = SystemThemeHelper.GetSystemTheme();
            }
#endif

            this.RequestedTheme = applicationTheme switch
            {
                Models.Domain.ApplicationTheme.Light => ElementTheme.Light,
                Models.Domain.ApplicationTheme.Dark => ElementTheme.Dark,
                Models.Domain.ApplicationTheme.Default => ElementTheme.Default,
                _ => throw new NotSupportedException(),
            };
        }
Esempio n. 5
0
        private void SetDarkLightToggleInitialState()
        {
            // Initialize the toggle to the current theme.
            var root = global::Windows.UI.Xaml.Window.Current.Content as FrameworkElement;

            switch (root.ActualTheme)
            {
            case ElementTheme.Default:
                DarkLightModeToggle.IsChecked = SystemThemeHelper.GetSystemApplicationTheme() == ApplicationTheme.Dark;
                break;

            case ElementTheme.Light:
                DarkLightModeToggle.IsChecked = false;
                break;

            case ElementTheme.Dark:
                DarkLightModeToggle.IsChecked = true;
                break;
            }
        }
Esempio n. 6
0
 private void ChangeTheme(object sender, RoutedEventArgs e)
 {
     SystemThemeHelper.SetTheme("aero", "normalcolor");
 }