DaisyThemeDropdown

Overview

DaisyThemeDropdown is a ComboBox listing available themes from DaisyThemeManager. It previews theme colors in a 2×2 dot grid and applies the selected theme. It syncs selection with the current theme when themes change externally.

How Theming Works

This control uses DaisyThemeManager internally, which works with Avalonia's ThemeDictionaries architecture:

Properties & Behavior

Property Description
SelectedTheme Name of the currently selected theme. Setting this applies the theme.
ItemsSource Auto-populated from DaisyThemeManager.AvailableThemes with preview brushes.
Sync Subscribes to ThemeChanged to update selection when themes change elsewhere.

Initialization Behavior

The dropdown automatically syncs to the current theme during construction:

This ensures apps can restore persisted theme preferences before constructing UI controls without worrying about dropdowns overriding the saved theme.

Quick Examples

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"

<!-- Default theme dropdown - shows all 35 themes with color previews -->
<controls:DaisyThemeDropdown Width="220" />

<!-- Binding selected theme to ViewModel -->
<controls:DaisyThemeDropdown SelectedTheme="{Binding CurrentTheme, Mode=TwoWay}" />
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.

Tips & Best Practices