DaisyThemeController is a toggle-based switch for applying Daisy themes via DaisyThemeManager. It supports multiple display modes (toggle, checkbox, swap, text/icon variants) and syncs IsChecked with the current theme. Switching updates CheckedTheme/UncheckedTheme and can auto-adopt new themes.
This control uses DaisyThemeManager internally, which works with Avalonia's ThemeDictionaries architecture:
RequestedThemeVariant triggers Avalonia's built-in resource refreshLight or Dark variant with its unique color paletteDaisyThemeLoader.ApplyThemeToApplication() instead| Property | Description |
|---|---|
Mode |
Visual mode: Toggle, Checkbox, Swap, ToggleWithText, ToggleWithIcons. |
UncheckedLabel / CheckedLabel |
Labels for light/dark (or custom) modes. |
UncheckedTheme / CheckedTheme |
Theme names to apply on off/on states (defaults: Light/Dark). |
DaisyThemeManager.ApplyTheme(...).DaisyThemeManager.ThemeChanged to sync IsChecked when theme changes externally.CheckedTheme/CheckedLabel update to that theme name.In your .axaml file (e.g., MainWindow.axaml), add the namespace and control:
<!-- Add at top of file -->
xmlns:controls="clr-namespace:Flowery.Controls;assembly=Flowery.NET"
<!-- Simple toggle - just drop it in, defaults to Light/Dark -->
<controls:DaisyThemeController Mode="Toggle" />
<!-- Animated sun/moon swap (as used in Gallery) -->
<controls:DaisyThemeController Mode="Swap" />
<!-- Custom theme pairing -->
<controls:DaisyThemeController Mode="ToggleWithText"
UncheckedTheme="Light" CheckedTheme="Synthwave"
UncheckedLabel="Light" CheckedLabel="Synthwave" />
Prerequisite: Your App.axaml must include in Application.Styles. If you're not using another base theme (like Semi or Material), add as the minimum required for core Avalonia controls to render properly.
UncheckedTheme aligned with your base theme so IsChecked=False reflects the default look.CheckedTheme to the latest applied theme.IsChecked if you need to track theme state elsewhere; the controller will still apply themes.