搜索

PythonReactSEOPDF
GitHub Skill

designing-avalonia-customcontrol-architecture

Defines the basic solution structure for AvaloniaUI Desktop Applications using CustomControl. Use when creating new AvaloniaUI projects or designing stand-alone control styles with ControlTheme.

NeverSight☆ 66 仓库 Stars19 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

6.5 Writing AXAML Code

  • When generating AXAML code, use CustomControl with ControlTheme for Stand-Alone Control Style
  • Purpose: Theme separation and minimizing style dependencies
6.5.1 AvaloniaUI Custom Control Library Project Structure

Recommended Project Structure:

YourAvaloniaSolution
├── YourCustomControlProject1/
│    ├── Properties/
│    │   ├── AssemblyInfo.cs            ← AssemblyInfo.cs definition
│    ├── Themes/
│    │   ├── Generic.axaml            ← ControlTheme definition
│    │   ├── CustomButton1.axaml       ← Individual control theme
│    │   └── CustomTextBox1.axaml      ← Individual control theme
│    ├── CustomButton1.cs
│    └── CustomTextBox1.cs
└── YourCustomControlProject2/
    ├── Properties/
    │   ├── AssemblyInfo.cs            ← AssemblyInfo.cs definition
    ├── Themes/
    │   ├── Generic.axaml            ← ControlTheme definition
    │   ├── CustomButton2.axaml       ← Individual control theme
    │   └── CustomTextBox2.axaml      ← Individual control theme
    ├── CustomButton2.cs
    └── CustomTextBox2.cs

6.6 ⚠️ Distinguishing ResourceInclude vs MergeResourceInclude

  • ResourceInclude: Used in regular ResourceDictionary files (Generic.axaml, Styles, etc.)
  • MergeResourceInclude: Used only in Application.Resources (App.axaml)

Advantages:

  • Complete separation of theme and logic based on ControlTheme
  • Flexible style variations through CSS Classes
  • State management via Pseudo Classes (:pointerover, :pressed, etc.)
  • Theme modularization through ResourceInclude
  • Work can be split by file for team collaboration
6.5.2 Key Differences Between WPF and AvaloniaUI
Item WPF AvaloniaUI
File Extension .xaml .axaml
Style Definition Style + ControlTemplate ControlTheme
State Management Trigger, DataTrigger Pseudo Classes, Style Selector
CSS Support ❌ ✅ (Classes attribute)
Resource Merging MergedDictionaries + ResourceDictionary MergedDictionaries + ResourceInclude
Dependency Props DependencyProperty StyledProperty, DirectProperty

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-03-11
索引更新时间
2026-03-11
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!