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. Preview brushes come from DaisyThemeManager.TryCreatePalette, including themes registered at runtime.
This control uses DaisyThemeManager internally, which manages the application's theme resources:
DaisyThemeManager.RegisterTheme appear in the list and use that factory for preview swatchesDaisyThemeLoader.ApplyThemeToApplication()| Property | Description |
|---|---|
SelectedTheme |
Name of the currently selected theme. Setting this applies the theme. |
| ItemsSource | Auto-populated from DaisyThemeManager.AvailableThemes with preview brushes from TryCreatePalette. |
| Sync | Subscribes to ThemeChanged and, while loaded, AvailableThemesChanged, so selection and the theme list stay current. |
AddTheme(originalName, displayName, preferred) |
Adds a standard, registered or product theme to this dropdown only, with its own display text and group. Selecting an added product theme registers and applies it. |
RemoveThemeOverride(originalName) |
Removes a local entry and restores the manager's entry, if any. |
The list honours DaisyThemeManager.ExcludedThemes, PreferredThemes and global AddTheme entries. Preferred entries come first, followed by a separator line. See DaisyThemeManager.
Local and global list customization applies to dropdowns that fill their own list. If the app sets ItemsSource, the dropdown shows that list unchanged.
The dropdown automatically syncs to the current theme during construction:
DaisyThemeManager.CurrentThemeName is already set (e.g., app restored theme from settings), the dropdown syncs to that theme without re-applying it.ApplyTheme.This ensures apps can restore persisted theme preferences before constructing UI controls without worrying about dropdowns overriding the saved theme.
In your .xaml file (e.g., MainWindow.xaml), add the namespace and control:
<!-- Add at top of file -->
xmlns:controls="using:Flowery.Controls"
<!-- 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.xaml must include Flowery.WinUI's theme resources in Application.Resources.MergedDictionaries:
<ResourceDictionary Source="ms-appx:///Flowery.WinUI/Themes/Generic.xaml" />
The dropdown automatically calculates dimensions based on the Size property:
MinWidth is computed to ensure all content fits:
DaisyResourceLookup.GetDefaultSwatchSize(Size) design tokenThis prevents the dropdown arrow from being clipped, especially at smaller sizes (ExtraSmall, Small).
The 5 color preview dots scale with the control size:
| Size | Swatch Diameter |
|---|---|
| ExtraSmall | 6px |
| Small | 8px |
| Medium | 10px |
| Large | 12px |
| ExtraLarge | 14px |
> Note: Setting Width below the computed MinWidth will be overridden. If you need a narrower dropdown, also set MinWidth explicitly (may cause visual clipping).
DaisyThemeController for quick toggle + full list selection.DaisyBase100Brush, etc.) are present for accurate previews.