
Avalonia Layout Zafiro
- 633 installs
- 44k repo stars
- Updated July 27, 2026
- sickn33/antigravity-awesome-skills
avalonia-layout-zafiro is a Claude skill that teaches developers to build clean Avalonia and Zafiro views using Xaml.Interaction.Behaviors instead of converter-heavy XAML while keeping UI logic out of ViewModels.
About
avalonia-layout-zafiro is a UI architecture skill from sickn33/antigravity-awesome-skills for Avalonia and Zafiro desktop applications. The guidance promotes Interaction.Behaviors for focus management, animations, and specialized event handling so views stay readable without excessive value converters or code-behind. Developers reach for avalonia-layout-zafiro when XAML grows converter-heavy, UI logic leaks into ViewModels, or reusable interaction patterns like UntouchedClassBehavior are needed on controls such as TextBox bindings. The skill emphasizes encapsulation, cleaner XAML, and independently testable behavior classes for cross-platform .NET desktop UI.
- Prefer Interaction.Behaviors for focus, animations, and UI-only event logic
- Minimize converters—favor ViewModel-formatted properties and MultiBinding
- Documented UntouchedClassBehavior-style pattern for encapsulated UI logic
- Guidance to simplify components before adding complex converters or behaviors
- Zafiro-oriented Avalonia layout conventions for maintainable XAML
Avalonia Layout Zafiro by the numbers
- 633 all-time installs (skills.sh)
- +3 installs in the week ending Jul 27, 2026 (Skillselion tracking)
- Ranked #537 of 2,277 Frontend Development skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill avalonia-layout-zafiroAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 633 |
|---|---|
| repo stars | ★ 44k |
| Security audit | 3 / 3 scanners passed |
| Last updated | July 27, 2026 |
| Repository | sickn33/antigravity-awesome-skills ↗ |
How do you keep Avalonia UI logic out of ViewModels?
Build clean Avalonia/Zafiro views with behaviors instead of converter-heavy XAML and keep UI logic out of ViewModels.
Who is it for?
.NET desktop developers building Avalonia or Zafiro apps who want maintainable XAML without converter sprawl.
Skip if: Web React or WPF-only projects that do not use Avalonia, Zafiro, or Xaml.Interaction.Behaviors.
When should I use this skill?
The user builds Avalonia or Zafiro views, mentions Interaction.Behaviors, or wants to move UI logic out of ViewModels and converters.
What you get
Behavior-based Avalonia XAML views with reusable interaction classes and reduced converter usage.
- Behavior-based XAML views
- Reusable interaction behavior classes
Files
Avalonia Layout with Zafiro.Avalonia
Master modern, clean, and maintainable Avalonia UI layouts.
Focus on semantic containers, shared styles, and minimal XAML.
🎯 Selective Reading Rule
Read ONLY files relevant to the layout challenge!
---
📑 Content Map
| File | Description | When to Read |
|---|---|---|
themes.md | Theme organization and shared styles | Setting up or refining app themes |
containers.md | Semantic containers (HeaderedContainer, EdgePanel, Card) | Structuring views and layouts |
icons.md | Icon usage with IconExtension and IconOptions | Adding and customizing icons |
behaviors.md | Xaml.Interaction.Behaviors and avoiding Converters | Implementing complex interactions |
components.md | Generic components and avoiding nesting | Creating reusable UI elements |
---
🔗 Related Project (Exemplary Implementation)
For a real-world example, refer to the Angor project: /mnt/fast/Repos/angor/src/Angor/Avalonia/Angor.Avalonia.sln
---
✅ Checklist for Clean Layouts
- [ ] Used semantic containers? (e.g.,
HeaderedContainerinstead ofBorderwith manual header) - [ ] Avoided redundant properties? Use shared styles in
axamlfiles. - [ ] Minimized nesting? Flatten layouts using
EdgePanelor generic components. - [ ] Icons via extension? Use
{Icon fa-name}andIconOptionsfor styling. - [ ] Behaviors over code-behind? Use
Interaction.Behaviorsfor UI-logic. - [ ] Avoided Converters? Prefer ViewModel properties or Behaviors unless necessary.
---
❌ Anti-Patterns
DON'T:
- Use hardcoded colors or sizes (literals) in views.
- Create deep nesting of
GridandStackPanel. - Repeat visual properties across multiple elements (use Styles).
- Use
IValueConverterfor simple logic that belongs in the ViewModel.
DO:
- Use
DynamicResourcefor colors and brushes. - Extract repeated layouts into generic components.
- Leverage
Zafiro.Avaloniaspecific panels likeEdgePanelfor common UI patterns.
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Interactions and Logic
To keep XAML clean and maintainable, minimize logic in views and avoid excessive use of converters.
🎭 Xaml.Interaction.Behaviors
Use Interaction.Behaviors to handle UI-related logic that doesn't belong in the ViewModel, such as focus management, animations, or specialized event handling.
<TextBox Text="{Binding Address}">
<Interaction.Behaviors>
<UntouchedClassBehavior />
</Interaction.Behaviors>
</TextBox>Why use Behaviors?
- Encapsulation: UI logic is contained in a reusable behavior class.
- Clean XAML: Avoids code-behind and complex XAML triggers.
- Testability: Behaviors can be tested independently of the View.
🚫 Avoiding Converters
Converters often lead to "magical" logic hidden in XAML. Whenever possible, prefer:
1. ViewModel Properties: Let the ViewModel provide the final data format (e.g., a string formatted for display). 2. MultiBinding: Use for simple logic combinations (And/Or) directly in XAML. 3. Behaviors: For more complex interactions that involve state or events.
When to use Converters?
Only use them when the conversion is purely visual and highly reusable across different contexts (e.g., BoolToOpacityConverter).
🧩 Simplified Interactions
If you find yourself needing a complex converter or behavior, consider if the component can be simplified or if the data model can be adjusted to make the view binding more direct.
Building Generic Components
Reducing nesting and complexity is achieved by breaking down views into generic, reusable components.
🧊 Generic Components
Instead of building large, complex views, extract recurring patterns into small UserControls.
Example: A generic "Summary Item"
Instead of repeating a Grid with labels and values:
<!-- ❌ BAD: Repeated Grid -->
<Grid ColumnDefinitions="*,Auto">
<TextBlock Text="Total:" />
<TextBlock Grid.Column="1" Text="{Binding Total}" />
</Grid>Create a generic component (or use EdgePanel with a Style):
<!-- ✅ GOOD: Use a specialized control or style -->
<EdgePanel StartContent="Total:" EndContent="{Binding Total}" Classes="SummaryItem" />📉 Flattening Layouts
Avoid deep nesting. Deeply nested XAML is hard to read and can impact performance.
- StackPanel vs Grid: Use
StackPanel(withSpacing) for simple linear layouts. - EdgePanel: Great for "Label - Value" or "Icon - Text - Action" rows.
- UniformGrid: Use for grids where all cells are the same size.
🔧 Component Granularity
- Atomical: Small controls like custom buttons or icons.
- Molecular: Groups of atoms like a
HeaderedContainerwith specific content. - Organisms: Higher-level sections of a page.
Aim for components that are generic enough to be reused but specific enough to simplify the parent view significantly.
Semantic Containers
Using the right container for the data type simplifies XAML and improves maintainability. Zafiro.Avalonia provides specialized controls for common layout patterns.
📦 HeaderedContainer
Prefer HeaderedContainer over a Border or Grid when a section needs a title or header.
<HeaderedContainer Header="Security Settings" Classes="WizardSection">
<StackPanel>
<!-- Content here -->
</StackPanel>
</HeaderedContainer>Key Properties:
Header: The content or string for the header.HeaderBackground: Brush for the header area.ContentPadding: Padding for the content area.
↔️ EdgePanel
Use EdgePanel to position elements at the edges of a container without complex Grid definitions.
<EdgePanel StartContent="{Icon fa-wallet}"
Content="Wallet Balance"
EndContent="$1,234.00" />Slots:
StartContent: Aligned to the left (or beginning).Content: Fills the remaining space in the middle.EndContent: Aligned to the right (or end).
📇 Card
A simple container for grouping related information, often used inside HeaderedContainer or as a standalone element in a list.
<Card Header="Enter recipient address:">
<TextBox Text="{Binding Address}" />
</Card>📐 Best Practices
- Use
Classesto apply themed variants (e.g.,Classes="Section",Classes="Highlight"). - Customize internal parts of the containers using templates in your styles when necessary, rather than nesting more controls.
Icon Usage
Zafiro.Avalonia simplifies icon management using a specialized markup extension and styling options.
🛠️ IconExtension
Use the {Icon} markup extension to easily include icons from libraries like FontAwesome.
<!-- Positional parameter -->
<Button Content="{Icon fa-wallet}" />
<!-- Named parameter -->
<ContentControl Content="{Icon Source=fa-gear}" />🎨 IconOptions
IconOptions allows you to customize icons without manually wrapping them in other controls. It's often used in styles to provide a consistent look.
<Style Selector="HeaderedContainer /template/ ContentPresenter#Header EdgePanel /template/ ContentControl#StartContent">
<Setter Property="IconOptions.Size" Value="20" />
<Setter Property="IconOptions.Fill" Value="{DynamicResource Accent}" />
<Setter Property="IconOptions.Padding" Value="10" />
<Setter Property="IconOptions.CornerRadius" Value="10" />
</Style>Common Properties:
IconOptions.Size: Sets the width and height of the icon.IconOptions.Fill: The color/brush of the icon.IconOptions.Background: Background brush for the icon container.IconOptions.Padding: Padding inside the icon container.IconOptions.CornerRadius: Corner radius if a background is used.
📁 Shared Icon Resources
Define icons as resources for reuse across the application.
<ResourceDictionary xmlns="https://github.com/avaloniaui">
<Icon x:Key="fa-wallet" Source="fa-wallet" />
</ResourceDictionary>Then use them with StaticResource if they are already defined:
<Button Content="{StaticResource fa-wallet}" />However, the {Icon ...} extension is usually preferred for its brevity and ability to create new icon instances on the fly.
Theme Organization and Shared Styles
Efficient theme organization is key to avoiding redundant XAML and ensuring visual consistency.
🏗️ Structure
Follow the pattern from Angor:
1. Colors & Brushes: Define in a dedicated Colors.axaml. Use DynamicResource to support theme switching. 2. Styles: Group styles by category (e.g., Buttons.axaml, Containers.axaml, Typography.axaml). 3. App-wide Theme: Aggregate all styles in a main Theme.axaml.
🎨 Avoiding Redundancy
Instead of setting properties directly on elements:
<!-- ❌ BAD: Redundant properties -->
<HeaderedContainer CornerRadius="10" BorderThickness="1" BorderBrush="Blue" Background="LightBlue" />
<HeaderedContainer CornerRadius="10" BorderThickness="1" BorderBrush="Blue" Background="LightBlue" />
<!-- ✅ GOOD: Use Classes and Styles -->
<HeaderedContainer Classes="BlueSection" />
<HeaderedContainer Classes="BlueSection" />Define the style in a shared axaml file:
<Style Selector="HeaderedContainer.BlueSection">
<Setter Property="CornerRadius" Value="10" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="{DynamicResource Accent}" />
<Setter Property="Background" Value="{DynamicResource SurfaceSubtle}" />
</Style>🧩 Shared Icons and Resources
Centralize icon definitions and other shared resources in Icons.axaml and include them in the MergedDictionaries of your theme or App.axaml.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="UI/Themes/Styles/Containers.axaml" />
<MergeResourceInclude Source="UI/Shared/Resources/Icons.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>Related skills
How it compares
Use avalonia-layout-zafiro for Avalonia behavior patterns rather than generic MVVM theory without XAML specifics.
FAQ
Why use behaviors in avalonia-layout-zafiro?
avalonia-layout-zafiro recommends Xaml.Interaction.Behaviors to encapsulate UI logic such as focus and animations in reusable classes, keeping Avalonia XAML clean and ViewModels free of view-specific code.
Which frameworks does avalonia-layout-zafiro target?
avalonia-layout-zafiro targets Avalonia and Zafiro cross-platform .NET desktop UI with XAML views and Interaction.Behaviors instead of excessive value converters.
Is Avalonia Layout Zafiro safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.