-
-
Notifications
You must be signed in to change notification settings - Fork 11
Change Theme or Accent color (Version before 5.0.0)
Click here for versions 5.0.0 and newer
Table of Contents
This service uses the singleton pattern so only one Class is initialized by software. In order to use it you have to use
AccentColorService.Current
instead of
new AccentColorService()
This method will set your software to use the user current defined Windows accent color as the software default accent color. (Enabled by default)
AccentColorService.Current.UpdateAccentsFromWindows();
This method will set your software to use a custom Color as your Accent Color and will ignore the Windows Accent color.
AccentColorService.Current.UpdateAccents(System.Windows.Media.Color.FromRgb(255, 0, 0));
This service uses the singleton pattern so only one Class is initialized by software. In order to use it you have to use
ThemeService.Current
instead of
new ThemeService()
This method will set your software current theme. (Light or Dark)
ThemeService.Current.ChangeTheme(WindowsTheme.Light);
This method will enable Mica on the specified window it is recommended to use the extension instead.
ThemeService.Current.EnableBackdrop(this, BackdropType.Mica, 20);
This method allows you to get the current Windows theme.
var currentTheme = ThemeService.GetWindowsTheme();
Console.WriteLine(currentTheme.ToString());
Console output: Dark (As I am using Dark Theme on Windows)
This method allows you to get the Ressource Uri for the specified theme.
var themeRessource = ThemeService.WindowsThemeToResourceTheme(WindowsTheme.Dark);
Console.WriteLine(themeRessource.ToString());
Console output: pack://application:,,,/MicaWPF;component/Styles/Themes/MicaDark.xaml
Will tell if the service is listening for theme change.
var currentThemeAwareness = ThemeService.Current.IsThemeAware;
Console.WriteLine(currentThemeAwareness); //True by default
Both services are accessible via DependencyInjection see dependency injection implementation.
The documentation is maintained by @Simnico99. This Library is distributed under an MIT License.