
Avalonia Layout Zafiro
Build clean Avalonia/Zafiro views with behaviors instead of converter-heavy XAML and keep UI logic out of ViewModels.
Overview
Avalonia Layout Zafiro is an agent skill for the Build phase that teaches Avalonia XAML layout and Interaction.Behaviors patterns to avoid converter-heavy views.
Install
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill avalonia-layout-zafiroWhat is this skill?
- 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
- 3 alternatives listed before defaulting to converters (ViewModel properties, MultiBinding, Behaviors)
Adoption & trust: 544 installs on skills.sh; 40.1k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Avalonia XAML is hard to maintain because converters and code-behind hide UI logic that should be testable and reusable.
Who is it for?
Solo builders implementing Avalonia + Zafiro UIs who want consistent XAML conventions from coding agents.
Skip if: Web React/Vue frontends, native Swift/Kotlin-only apps, or teams that do not use Avalonia.
When should I use this skill?
Working on Avalonia/Zafiro views, Interaction.Behaviors, or when reducing converter and code-behind complexity in XAML.
What do I get? / Deliverables
Agents produce cleaner views with behaviors and ViewModel-ready bindings aligned to Zafiro/Avalonia best practices.
- Refactored XAML using behaviors and direct bindings
- Reusable behavior classes for UI interactions
Recommended Skills
Journey fit
Phase-specific to Build because the skill teaches desktop/cross-platform UI composition patterns during product implementation. Frontend subphase is the right shelf for XAML layout, Interaction.Behaviors, and view binding discipline.
How it compares
Framework-specific frontend skill, not a generic MVVM tutorial or a visual design system generator.
Common Questions / FAQ
Who is avalonia-layout-zafiro for?
Indie and solo .NET developers building Avalonia desktop or cross-platform apps with Zafiro-style architecture.
When should I use avalonia-layout-zafiro?
Use during Build frontend work when authoring or refactoring XAML, adding behaviors, or deciding whether a converter belongs in the view.
Is avalonia-layout-zafiro safe to install?
It is pattern documentation; review the Security Audits panel on this Prism page and vet the sickn33/antigravity-awesome-skills repo before install.
SKILL.md
READMESKILL.md - Avalonia Layout Zafiro
# 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. ```xml <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 `UserControl`s. ### Example: A generic "Summary Item" Instead of repeating a `Grid` with labels and values: ```xml <!-- ❌ 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): ```xml <!-- ✅ 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` (with `Spacing`) 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 `HeaderedContainer` with 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. ```xml <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. ```xml <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 groupi