Theming Engine
EarTrumpet is designed to seamlessly integrate with the Windows user interface. To achieve this, it includes a custom WPF theming engine that dynamically adapts to the user's system settings.
Supported Theme Configurations
The theming engine supports all major Windows theme configurations:
- Light or Dark Theme: Adapts to both the system-wide and per-app theme settings.
- Accent Color: Applies the user's chosen accent color (in dark mode).
- Transparency: Enables acrylic/blur effects on window backgrounds when transparency is enabled in Windows.
- High Contrast: Fully supports all Windows high contrast themes for accessibility.
The Theme:Brush
Markup Extension
Instead of defining static colors in XAML, EarTrumpet uses a custom markup extension called Theme:Brush
. This allows UI elements to declare their color properties in a semantic way, with the actual color value being resolved at runtime based on the current theme.
Basic Usage
A simple brush definition might look like this:
<TextBlock Theme:Brush.Foreground="Text" />
This tells the theming engine to apply the standard text color for the current theme.
Conditional Values
The extension supports defining different colors for light, dark, and high contrast modes in a single line:
<Rectangle Theme:Brush.Stroke="Light=LightSecondaryText, Dark=LightDisabledText, HighContrast=WindowText" />
You can also use the {Theme}
variable, which is replaced with Light
or Dark
at runtime:
<Rectangle Theme:Brush.Stroke="Theme={Theme}ChromeWhite, HighContrast=Highlight" />
Scopes and References
The theming engine also supports scopes, which allow for different color values depending on the context (e.g., the main flyout vs. a settings window). This is defined using the Theme:Options.Scope
attached property in XAML.
Example of a scoped brush value:
<Border Theme:Brush.Background=":=Transparent, Flyout:FlyoutBackground, Flyout:HighContrast=Window" />
Here, the background is transparent by default but uses the FlyoutBackground
color reference when its scope is Flyout
.
This powerful system allows EarTrumpet to maintain a native look and feel that perfectly matches the user's personalization settings.