Class ApplicationThemeManager
- Namespace
- Wpf.Ui.Appearance
- Assembly
- Wpf.Ui.dll
Allows to manage the application theme by swapping resource dictionaries containing dynamic resources with color information.
public static class ApplicationThemeManager
- Inheritance
-
ApplicationThemeManager
- Inherited Members
Examples
ApplicationThemeManager.Apply(
ApplicationTheme.Light
);
if (ApplicationThemeManager.GetAppTheme() == ApplicationTheme.Dark)
{
ApplicationThemeManager.Apply(
ApplicationTheme.Light
);
}
ApplicationThemeManager.Changed += (theme, accent) =>
{
Debug.WriteLine($"Application theme changed to {theme.ToString()}");
};
Methods
Apply(FrameworkElement)
Applies Resources in the frameworkElement
.
public static void Apply(FrameworkElement frameworkElement)
Parameters
frameworkElement
FrameworkElement
Apply(ApplicationTheme, WindowBackdropType, bool)
Changes the current application theme.
public static void Apply(ApplicationTheme applicationTheme, WindowBackdropType backgroundEffect = WindowBackdropType.Mica, bool updateAccent = true)
Parameters
applicationTheme
ApplicationThemeTheme to set.
backgroundEffect
WindowBackdropTypeWhether the custom background effect should be applied.
updateAccent
boolWhether the color accents should be changed.
ApplySystemTheme()
public static void ApplySystemTheme()
ApplySystemTheme(bool)
public static void ApplySystemTheme(bool updateAccent)
Parameters
updateAccent
bool
GetAppTheme()
Gets currently set application theme.
public static ApplicationTheme GetAppTheme()
Returns
- ApplicationTheme
Unknown if something goes wrong.
GetSystemTheme()
Gets currently set system theme.
public static SystemTheme GetSystemTheme()
Returns
- SystemTheme
Unknown if something goes wrong.
IsAppMatchesSystem()
Gets a value that indicates whether the application is matching the system theme.
public static bool IsAppMatchesSystem()
Returns
IsHighContrast()
Gets a value that indicates whether the application is currently using the high contrast theme.
public static bool IsHighContrast()
Returns
IsMatchedDark()
Checks if the application and the operating system are currently working in a dark theme.
public static bool IsMatchedDark()
Returns
IsMatchedLight()
Checks if the application and the operating system are currently working in a light theme.
public static bool IsMatchedLight()
Returns
IsSystemHighContrast()
Gets a value that indicates whether the Windows is currently using the high contrast theme.
public static bool IsSystemHighContrast()
Returns
Events
Changed
Event triggered when the application's theme is changed.
public static event ThemeChangedEvent? Changed