Logo Avalonia Styling

Avalonia Styling

Cộng đồng
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.

Tổng quan

Nhà phát hànhlinuxdevel
Kho mãAvalonia-skills
Tên kỹ năngavalonia-styling
Sao
50
Bản fork
4
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Đầy đủ trong hướng dẫn

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được linuxdevel công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Avalonia Styling trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/linuxdevel/Avalonia-skills/tree/main/skills/avalonia/avalonia-styling
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

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
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Avalonia Styling trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Avalonia Styling ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Avalonia Styling không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

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.

Câu hỏi thường gặp

Kỹ năng AI Avalonia Styling làm được gì?

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.

Vì sao nên dùng Avalonia Styling trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Avalonia Styling là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Avalonia Styling trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/linuxdevel/Avalonia-skills/tree/main/skills/avalonia/avalonia-styling. TypingMind đọc tệp SKILL.md và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Avalonia Styling?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Avalonia Styling với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Avalonia Styling với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Avalonia Styling có miễn phí không?

Có. Kỹ năng này được linuxdevel phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇