Primary WPF APIs:
Primary Avalonia APIs:
ThemeVariant (Light, Dark, Default)Application.RequestedThemeVariantThemeVariantScopeResourceDictionary.ThemeDictionaries| WPF | Avalonia |
|---|---|
| theme-specific dictionaries | ThemeDictionaries keyed by ThemeVariant |
| app-level theme changes | Application.RequestedThemeVariant |
| subtree theme overrides | ThemeVariantScope |
WPF XAML concept:
<!-- Theme dictionaries chosen by current system theme -->
Avalonia XAML:
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="ShellBackground" Color="#F8F9FB" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="ShellBackground" Color="#1F2430" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
<Border Background="{DynamicResource ShellBackground}" />
using Avalonia;
using Avalonia.Styling;
Application.Current!.RequestedThemeVariant = ThemeVariant.Dark;
Subtree override:
<ThemeVariantScope RequestedThemeVariant="Light">
<ContentPresenter />
</ThemeVariantScope>
DynamicResource for theme-dependent values.ThemeVariantScope.