Logo vun Avalonia Styling

Avalonia Styling

Communautéit
linuxdevel
avalonia-styling

Use when applying styles, control themes, pseudoclasses, style selectors, theme variants, or custom fonts in Avalonia. Covers Style vs ControlTheme distinction, selector syntax, nested styles, light/dark theme variants, style sharing via avares://, StyleKeyOverride, and style precedence rules.

Iwwersiicht

Editeurlinuxdevel
RepositoryAvalonia-skills
Skill-Nummavalonia-styling
Stären
50
Forks
4
Matgeliwwert Fichieren
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Vum linuxdevel op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Avalonia Styling an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/linuxdevel/Avalonia-skills/tree/main/skills/avalonia/avalonia-styling
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/linuxdevel/Avalonia-skills.git /tmp/Avalonia-skills
mkdir -p .claude/skills
cp -r /tmp/Avalonia-skills/skills/avalonia/avalonia-styling .claude/skills/avalonia-styling
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Avalonia Styling an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Avalonia Styling automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Avalonia Styling net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Avalonia Styling

Overview

Three mechanisms for visual styling in Avalonia:

MechanismAnalogous toUse for
StyleCSSApp-specific visual rules, typography, spacing, state
ControlThemeWPF Style + ControlTemplateRestyling entire control appearance (lookless)
ContainerQueryCSS container queriesResponsive styles based on container size

Styles cascade up the logical tree. ControlThemes live in Resources, not Styles.


Writing Styles

Selector + Setters. Place in Window.Styles, UserControl.Styles, or App.axaml for global.

xml
<Window.Styles>
    <Style Selector="TextBlock.h1">
        <Setter Property="FontSize" Value="24"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <!-- Nested: ^ refers to parent selector (TextBlock.h1) -->
        <Style Selector="^:pointerover">
            <Setter Property="Foreground" Value="Red"/>
        </Style>
    </Style>
</Window.Styles>

Multiple setters, one selector:

xml
<Style Selector="Button.primary">
    <Setter Property="Background" Value="#0078D4"/>
    <Setter Property="Foreground" Value="White"/>
    <Setter Property="Padding" Value="16,8"/>
</Style>

Style Selector Syntax

SelectorSyntaxMatches
TypeButtonAll Buttons
Class.myClassControls with that style class
Type + ClassButton.primaryButtons with class primary
Name#myNameControl with x:Name="myName"
Direct childStackPanel > ButtonButton as direct child of StackPanel
DescendantStackPanel ButtonAny Button inside StackPanel
Pseudoclass:pointeroverState-based match
Property value[IsChecked=True]Property equals value
Template part/template/ ContentPresenterElement inside ControlTemplate
Nesting^Parent selector (nested styles only)
OrButton, TextBlockEither type
Not:not(.primary)Negation
Is (type check):is(Button)Includes subtypes

Pseudoclasses

Built-in: :pointerover, :pressed, :disabled, :focus, :focus-within, :focus-visible, :checked, :unchecked, :indeterminate, :selected, :expanded, :collapsed, :empty, :nth-child(n), :nth-last-child(n), :first-child, :last-child

Custom pseudoclass in code-behind or ViewModel:

csharp
// In a custom control
PseudoClasses.Set(":loading", isLoading);

The extension class was renamed PseudolassesExtensions → PseudoClassesExtensions (12.0+) (typo fix; only matters for explicit static calls, e.g. PseudoClassesExtensions.Set(classes, ":x", true)).

Then target in XAML:

xml
<Style Selector="local|MyControl:loading">
    <Setter Property="Opacity" Value="0.5"/>
</Style>

Style Classes

Declare on control:

xml
<Button Classes="primary large">Click</Button>

Add/remove in code:

csharp
myButton.Classes.Add("active");
myButton.Classes.Remove("active");
myButton.Classes.Set("active", condition); // toggle

Conditional class binding:

xml
<Button Classes.active="{Binding IsActive}"/>

Multiple classes:

xml
<Button Classes.primary="{Binding IsPrimary}" Classes.large="{Binding IsLarge}"/>

Control Themes

ControlThemes replace the entire visual tree of a control. Must go in Resources, not Styles.

xml
<Application.Resources>
    <ControlTheme x:Key="{x:Type Button}" TargetType="Button">
        <Setter Property="Background" Value="#E0E0E0"/>
        <Setter Property="Template">
            <ControlTemplate>
                <Border Background="{TemplateBinding Background}"
                        CornerRadius="4"
                        Padding="{TemplateBinding Padding}">
                    <ContentPresenter Content="{TemplateBinding Content}"/>
                </Border>
            </ControlTemplate>
        </Setter>
        <!-- State styles inside ControlTheme -->
        <Style Selector="^:pointerover /template/ Border">
            <Setter Property="Background" Value="#C0C0C0"/>
        </Style>
        <Style Selector="^:pressed /template/ Border">
            <Setter Property="Background" Value="#A0A0A0"/>
        </Style>
    </ControlTheme>
</Application.Resources>

Extend existing theme with BasedOn:

xml
<ControlTheme x:Key="OutlineButton" TargetType="Button"
              BasedOn="{StaticResource {x:Type Button}}">
    <Setter Property="BorderThickness" Value="2"/>
    <Setter Property="Background" Value="Transparent"/>
</ControlTheme>

Apply a named ControlTheme:

xml
<Button Theme="{StaticResource OutlineButton}">Outlined</Button>

Theme Variants (Light / Dark)

Set on Window or Application:

xml
<Window RequestedThemeVariant="Dark">
csharp
Application.Current!.RequestedThemeVariant = ThemeVariant.Dark;

Theme-variant resources:

xml
<ResourceDictionary>
    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Light">
            <SolidColorBrush x:Key="SurfaceBrush" Color="#FFFFFF"/>
        </ResourceDictionary>
        <ResourceDictionary x:Key="Dark">
            <SolidColorBrush x:Key="SurfaceBrush" Color="#1E1E1E"/>
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>

Consume with DynamicResource (not StaticResource):

xml
<Border Background="{DynamicResource SurfaceBrush}"/>

Built-in Themes

xml
<!-- App.axaml -->
<Application.Styles>
    <FluentTheme/>
    <!-- or -->
    <SimpleTheme/>
</Application.Styles>

NuGet packages:

  • Avalonia.Themes.Fluent — Microsoft Fluent design
  • Avalonia.Themes.Simple — minimal, no external dependencies

Sharing Styles

Include an external .axaml file:

xml
<Window.Styles>
    <StyleInclude Source="avares://MyApp/Styles/Buttons.axaml"/>
</Window.Styles>

Or at app level:

xml
<Application.Styles>
    <FluentTheme/>
    <StyleInclude Source="avares://MyApp/Styles/Global.axaml"/>
</Application.Styles>

Merge ResourceDictionary:

xml
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceInclude Source="avares://MyApp/Resources/Colors.axaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

avares:// URI scheme references embedded resources from the assembly. The format is avares://AssemblyName/Path/To/File.axaml.


StyleKeyOverride

Causes a custom control subclass to pick up styles targeting its base type:

csharp
public class MyButton : Button
{
    // This control will be styled as Button, not MyButton
    protected override Type StyleKeyOverride => typeof(Button);
}

Useful when subclassing a control only for behavior changes, not visual identity.

IStyleable (with its explicit StyleKey implementation) was removed in 12 — use StyleKeyOverride / StyledElement:

csharp
// (11.x only, removed in 12.0)  class MyButton : Button, IStyleable { Type IStyleable.StyleKey => typeof(Button); }

ContainerQuery (Responsive Styles)

xml
<Style Selector="local|MyPanel">
    <Style Selector="^ /template/ TextBlock">
        <ContainerQuery MinWidth="400">
            <Setter Property="FontSize" Value="18"/>
        </ContainerQuery>
        <ContainerQuery MaxWidth="399">
            <Setter Property="FontSize" Value="12"/>
        </ContainerQuery>
    </Style>
</Style>

Limitations in 12

  • (12.0+) Window.WindowState is a direct property, not styleable — <Setter Property="WindowState" .../> no longer works. Set it in code/XAML attribute or bind it.
  • (12.0+) Style-triggered animations stop on hidden controls; add Animation.PlaybackBehavior="Always" to keep running (see avalonia-graphics-animation).
  • Theme variants (RequestedThemeVariant, ThemeDictionaries, ThemeVariant), ControlTheme, BasedOn, ContainerQuery: unchanged in 11.3/12.x.

Style Precedence (Highest to Lowest)

  1. Inline property set (e.g., <Button Background="Red"/>)
  2. Animations
  3. Template bindings ({TemplateBinding})
  4. Local style (closest scope — Window or UserControl)
  5. Inherited styles (further up logical tree — App.axaml)

Community Themes & Icon Libraries

Themes

ThemeNuGet / RepoStyle
Material.AvaloniaMaterial.AvaloniaGoogle Material Design theme
Semi.AvaloniaSemi.AvaloniaSemi Design (modern, clean)
SukiUISukiUIFlat design, highly customizable
ShadUIGitHub: accntech/shad-uishadcn/ui inspired, modern
FluentAvaloniaFluentAvaloniaWinUI3 Fluent controls + theme
Ursa.AvaloniaIrihi.UrsaFull UI library with rich controls
AntDesign.AvaloniaGitHub: MicroSugarDeveloperOrg/AntDesign.AvaloniaAnt Design theme
Neumorphism.AvaloniaGitHub: flarive/Neumorphism.AvaloniaNeumorphism soft-UI design
Classic.AvaloniaGitHub: BAndysc/Classic.AvaloniaWindows 9x retro theme
Pipboy.AvaloniaGitHub: NeverMorewd/Pipboy.AvaloniaFallout 4 Pip-Boy inspired theme
Huskui.AvaloniaGitHub: d3ara1n/Huskui.AvaloniaModern, ParkUI/Radix-inspired
Citrus.AvaloniaCitrus.AvaloniaModern styles for built-in controls
WPFDarkThemeGitHub: AngryCarrot789/WPFDarkThemeCompact soft dark theme

Icon Libraries

LibraryNuGetIcons
Icons.AvaloniaProjektanker.Icons.AvaloniaFontAwesome, Material, and more
IconPacks.AvaloniaMahApps.Metro.IconPacks.Avalonia21,000+ icons from multiple packs
Material.Icons.AvaloniaMaterial.Icons.Avalonia6000+ Material Design Icons
HeroIcons.AvaloniaGitHub: russkyc/heroicons-avaloniaHeroicons set
Lucide.AvaloniaLucide.AvaloniaLucide icon library

CSS-like Styling

  • Nlnet.Avalonia.Css — write Avalonia styles in CSS syntax (Nlnet.Avalonia.Css)

Common Mistakes

  • Using WPF Triggers — does not exist in Avalonia. Use pseudoclasses + nested styles instead.
  • Forgetting ^ in nested selectors — <Style Selector=":pointerover"> inside another Style does not scope to the parent; must be <Style Selector="^:pointerover">.
  • Styling Window.WindowState (12.0+) — direct property, not settable from a Style; set directly.
  • Putting ControlTheme in Window.Styles — ControlThemes must go in Window.Resources or Application.Resources, not Styles.
  • Using StaticResource for theme-variant resources — theme variant resources must be referenced with DynamicResource to react to variant changes at runtime.
  • Confusing Styles and ControlThemes — Styles add/override individual property values; ControlThemes replace the entire visual template. If you only need color or font changes, use a Style.
  • /template/ selector outside ControlTheme — the /template/ segment only works when targeting elements inside a ControlTemplate, typically from within a ControlTheme state style.

Heefeg gestallte Froen

Wat mécht de KI-Skill Avalonia Styling?

Use when applying styles, control themes, pseudoclasses, style selectors, theme variants, or custom fonts in Avalonia. Covers Style vs ControlTheme distinction, selector syntax, nested styles, light/dark theme variants, style sharing via avares://, StyleKeyOverride, and style precedence rules.

Firwat Avalonia Styling op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Avalonia Styling besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Avalonia Styling an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/linuxdevel/Avalonia-skills/tree/main/skills/avalonia/avalonia-styling an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Avalonia Styling benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Avalonia Styling benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Avalonia Styling domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Avalonia Styling gratis?

Jo. De Skill gëtt vum linuxdevel ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇