Table of Contents

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 ApplicationTheme

Theme to set.

backgroundEffect WindowBackdropType

Whether the custom background effect should be applied.

updateAccent bool

Whether 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

bool

true if the application has the same theme as the system.

IsHighContrast()

Gets a value that indicates whether the application is currently using the high contrast theme.

public static bool IsHighContrast()

Returns

bool

true if application uses high contrast theme.

IsMatchedDark()

Checks if the application and the operating system are currently working in a dark theme.

public static bool IsMatchedDark()

Returns

bool

IsMatchedLight()

Checks if the application and the operating system are currently working in a light theme.

public static bool IsMatchedLight()

Returns

bool

IsSystemHighContrast()

Gets a value that indicates whether the Windows is currently using the high contrast theme.

public static bool IsSystemHighContrast()

Returns

bool

true if system uses high contrast theme.

Events

Changed

Event triggered when the application's theme is changed.

public static event ThemeChangedEvent? Changed

Event Type

ThemeChangedEvent