Skip to main content

ApplicationThemeManager

C# API / Fluence.Wpf

  • Assembly: Fluence.Wpf
  • Namespace: Fluence.Wpf
public static class ApplicationThemeManager

Manages Fluence.Wpf theme resource dictionaries, accent coordination, and runtime theme changes.

Remarks: Apply delegates to the internal theme engine, which publishes one computed colors-plus-brushes dictionary at slot [0] and replaces it on every change.

C# source

Properties​

CurrentBackdrop​

public static WindowBackdropType CurrentBackdrop { get; }

Gets the currently requested backdrop type.

CurrentTheme​

public static ApplicationTheme CurrentTheme { get; }

Gets the currently requested theme (may be Auto).

IsAppInDarkMode​

public static bool IsAppInDarkMode { get; }

Gets a value indicating whether the Windows app color mode is currently Dark. Reflects the live registry value; independent of CurrentTheme.

IsSystemInDarkMode​

public static bool IsSystemInDarkMode { get; }

Gets a value indicating whether the Windows system (window-chrome) color mode is currently Dark. Reflects the live registry value; independent of CurrentTheme.

ResolvedTheme​

public static ApplicationTheme ResolvedTheme { get; }

Gets the concrete theme (Light, Dark, or HighContrast) that was resolved and applied during the most recent theme pipeline run (that is, the last call to Apply or to any ApplicationAccentColorManager apply method (ApplySystemAccent or ApplyCustomAccent), whichever ran last. When CurrentTheme is Auto, this reflects the OS theme at the time of that last pipeline run; it does not update automatically when the OS theme changes without a subsequent pipeline run. Before the first pipeline run, this property returns Light as the pre-initialization default.

Methods​

Apply​

public static void Apply(ApplicationTheme theme, WindowBackdropType backdrop = WindowBackdropType.Auto)

Initializes the theme resource stack or applies a later theme change.

Remarks: The first call seeds the three resource slots ([0] computed colors and brushes, [1] Typography, [2] Generic). Later calls replace the computed slot so DynamicResource consumers re-resolve. Visible FluenceWindow instances fade their previous WPF appearance over the newly published resources when client-area motion is enabled; the resources themselves still change immediately.

A call whose computed output is identical to the last published one does not rebuild or replace the computed slot; the theme engine gates that on a fingerprint of every input to the pipeline. CurrentTheme and CurrentBackdrop are still assigned, because they record the caller's request and remain observable even when the resolved colors do not move (for example Auto resolving to the same concrete theme as an explicit request, or a backdrop change that no computed brush depends on). Changed therefore fires when either the computed dictionary was republished or the requested theme or backdrop actually changed, and is suppressed only when the call was a true no-op in both respects. A publish that fails because Current is null counts as no publish, so an early-startup call that also repeats the current request raises nothing; the state assignments still happen and the next call retries the publish.

Parameter theme: The requested application theme. Use Auto to follow Windows app theme settings.

Parameter backdrop: The requested window backdrop policy retained for CurrentBackdrop consumers.

ApplySystemTheme​

public static void ApplySystemTheme()

Re-applies with Auto to pick up system changes.

Events​

Changed​

public static event EventHandler<ThemeChangedEventArgs>? Changed

Raised when Apply publishes resources or changes the requested theme or backdrop. Accent-only apply methods do not raise this event.