Theming
WinUI 3 supports tri-state theming: Light, Dark, and High Contrast.
- Set app-level theme via
Application.RequestedTheme, override per-element withFrameworkElement.RequestedTheme - Colors and brushes MUST use
ThemeResource(notStaticResource) — enables runtime theme switching - Semantic color resources (
TextFillColorPrimary,CardBackgroundFillColorDefault) SHOULD be used instead of hex values - Define custom theme-aware colors in a
ResourceDictionarywithDefault/Light/Darktheme dictionaries
<!-- Good: semantic theme resource -->
<TextBlock Foreground="{ThemeResource TextFillColorPrimaryBrush}" />
<!-- Bad: hard-coded color -->
<TextBlock Foreground="#FFFFFF" />