Refactor Avalonia UI Layouts with Zafiro
Skill for clean Avalonia UI layouts using Zafiro.Avalonia's semantic containers, shared styles, and minimal XAML nesting.
Why it matters
Refactor your Avalonia UI applications to use modern, clean, and maintainable layouts. This skill focuses on semantic containers, shared styles, and minimal XAML for improved code quality and developer experience.
Outcomes
What it gets done
Implement semantic containers like HeaderedContainer and EdgePanel.
Organize and apply shared styles to reduce XAML redundancy.
Minimize UI nesting by leveraging generic components and panels.
Integrate icons efficiently using IconExtension and IconOptions.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-avalonia-layout-zafiro | bash Overview
Avalonia Layout with Zafiro.Avalonia
A skill for building clean Avalonia UI layouts with Zafiro.Avalonia's semantic containers, shared styles, extension-based icons, and Behaviors over Converters. Use for structuring Avalonia + Zafiro.Avalonia views, themes, icons, or UI behaviors; not for ViewModel-side business logic.
What it does
This skill covers building modern, clean, maintainable Avalonia UI layouts using Zafiro.Avalonia, focused on semantic containers, shared styles, and minimal XAML. It's organized as a selective content map read only as needed: themes.md (theme organization and shared styles), containers.md (semantic containers like HeaderedContainer, EdgePanel, Card), icons.md (icon usage via IconExtension and IconOptions), behaviors.md (Xaml.Interaction.Behaviors and avoiding Converters), and components.md (generic reusable components, avoiding excessive nesting). A real-world reference implementation is pointed to in the Angor project's Avalonia solution.
Its clean-layout checklist: use semantic containers (e.g. HeaderedContainer instead of a Border with a manually built header), avoid redundant properties by using shared styles in axaml files, minimize nesting by flattening layouts with EdgePanel or generic components, add icons via the {Icon fa-name} extension with IconOptions for styling, prefer Interaction.Behaviors over code-behind for UI logic, and avoid IValueConverter for simple logic that belongs in the ViewModel instead.
Anti-patterns flagged: hardcoded colors/sizes as literals in views (use DynamicResource instead), deep nesting of Grid and StackPanel, repeating visual properties across elements instead of using Styles, and reaching for IValueConverter when a ViewModel property or Behavior would do.
When to use - and when NOT to
Use this when structuring or refining Avalonia UI views and layouts, setting up or adjusting app themes, adding icons, or implementing UI interactions/behaviors in an Avalonia + Zafiro.Avalonia project.
Not applicable outside Avalonia/Zafiro.Avalonia, and not for ViewModel-side business logic - this skill is specifically about view/layout structure, not application logic.
Inputs and outputs
Inputs: the specific layout challenge at hand (theming, container structure, icons, or interaction behaviors).
Outputs: XAML using semantic Zafiro.Avalonia containers, shared styles instead of repeated inline properties, flattened layouts via EdgePanel or generic components, extension-based icon usage, and Behavior-based interactions instead of Converters or code-behind.
Integrations
Avalonia UI, Zafiro.Avalonia (semantic containers, panels), Xaml.Interaction.Behaviors, with the Angor project's Avalonia solution as a reference implementation.
Who it's for
.NET developers building Avalonia UIs with Zafiro.Avalonia who need concrete do/don't guidance for clean, maintainable, minimally-nested XAML layouts.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.