UI components, controls, dialogs, behaviors, and helpers for Avalonia applications. Includes reactive patterns, cross-platform support (desktop, mobile, browser), and source generators.
Get Started
| Product | Versions |
|---|---|
| .NET |
README
Zafiro.Avalonia
A UI components library for Avalonia 11.3.x that provides controls, dialogs, behaviors, and helpers for desktop, mobile, and browser applications. Built with ReactiveUI, a strong functional-reactive orientation (Result<T>, Maybe<T>, IObservable<T>), and absolute respect for the MVVM pattern β no logic in views, no UI in ViewModels.
Packages
Getting Started
dotnet add package Zafiro.Avalonia
For dialogs:
dotnet add package Zafiro.Avalonia.Dialogs
For auto-generated view locators and section registrations (recommended):
dotnet add package Zafiro.Avalonia.Generators
Quick Start
Application Bootstrap with Connect
Wire up your app in one line β works on Desktop, Mobile, and Browser:
public override void OnFrameworkInitializationCompleted()
{
this.Connect(() => new MainView(), view => CompositionRoot.Create(view), () => new MainWindow());
base.OnFrameworkInitializationCompleted();
}
Connect handles IClassicDesktopStyleApplicationLifetime and ISingleViewApplicationLifetime automatically, so the same code runs everywhere.
Shell, Sections, and Navigation
A section-based navigation system integrated with Microsoft.Extensions.DependencyInjection:
ServiceCollection services = new();
services.AddSingleton<IShell, Shell>();
services.AddSingleton(DialogService.Create());
services.AddScoped<INavigator>(provider => new Navigator(provider, logger, RxApp.MainThreadScheduler));
services.AddAllSectionsFromAttributes(logger); // auto-discovers [Section] ViewModels
services.AddTransient<MainViewModel>();
var serviceProvider = services.BuildServiceProvider();
return serviceProvider.GetRequiredService<MainViewModel>();
Combined with Zafiro.Avalonia.Generators, sections are discovered from [Section] attributes and registered automatically.
Dialogs and Wizards
Dialogs that work on both desktop and mobile:
Result<Maybe<T>> result = await dialog.ShowAndGetResult(viewModel, "Title");
Build multi-step wizards declaratively with SlimWizard:
var wizard = WizardBuilder
.StartWith(() => new Page1ViewModel(), "Step 1")
.NextWith(model => model.Continue.Enhance("Next"))
.Then(result => new Page2ViewModel(result), "Step 2")
.NextWhenValid((vm, prev) => Result.Success(vm.Text!))
.WithCompletionFinalStep();
EnhancedCommand
Wraps ReactiveCommand with UX metadata (text, icon, name) and busy state β distinguishing between busy (executing) and disabled (can't execute) via IEnhancedCommand:
var command = ReactiveCommand.CreateFromTask(() => DoSomething());
var enhanced = command.Enhance("Save", name: "save");
// enhanced.IsBusy tracks execution; enhanced.CanExecute tracks enablement
View Locators
Automatically resolves Views for ViewModels by naming convention (MainViewModel β MainView) and by x:DataType discovery via source generators:
DataTemplates.Add(new NamingConventionViewLocator());
With Zafiro.Avalonia.Generators, x:DataType declarations in .axaml files are discovered at compile time and registered automatically.
Key Features
Navigation and Shell
- Shell / ShellView β Section-based application shell with sidebar navigation.
- Navigator β Observable navigation stack integrated with DI.
- SectionStrip β Tab-like section navigation with grouping support.
- Sections auto-registration β Source generator discovers
[Section]ViewModels and wires DI.
Controls
| Control | Description |
|---|---|
| HeaderedContainer | Content with header, footer, and configurable spacing |
| EdgePanel | Panel with Start, Content, and End regions |
| EnhancedButton | Button with icon, role-based theming, and box shadow |
| Loading | Loading indicator with content transition |
| BalancedWrapGrid | Wrap panel with balanced column widths and MaxItemWidth |
| MasterDetailsView | Side list with detail panel, responsive layout |
| ResponsivePresenter | Width-based content swap (Narrow/Wide + Breakpoint) |
| StepIndicator | Visual step progress for wizards |
Services
- DialogService β Show dialogs from ViewModels without coupling to the View layer.
- NotificationService β Push notifications from ViewModels.
- ILauncherService β Open URLs and files from ViewModels.
Commands and Selection
- EnhancedCommand β
ReactiveCommandwrapper with text/icon metadata, busy/disabled distinction viaIEnhancedCommand. - ReactiveSelection β Observable selection model with multi-select support.
- CommandPool / EnqueueCommandAction β Throttled, pooled command execution.
Helpers
Connectβ One-line app bootstrap for all platforms (Desktop, Mobile, Browser).- NamingConventionViewLocator + DataTypeViewLocator β Convention and
x:DataTypebased ViewModel β View resolution. - IconExtension β Unified icon markup extension supporting Projektanker and SVG providers.
- ReturnExtension β Markup extension for returning observables in design-time data.
Samples
The solution includes runnable samples that demonstrate all features:
# Desktop
dotnet run --project samples/TestApp/TestApp.Desktop
# Browser (WASM)
dotnet run --project samples/TestApp/TestApp.Browser
Philosophy
- Functional + Reactive β
Result<T>,Maybe<T>, andIObservable<T>throughout. No exceptions for control flow, explicit error handling everywhere. - MVVM purist β Strict separation: no UI logic in ViewModels, no business logic in Views. Services are injected, never resolved from Views.
- Composition over inheritance β Small, composable building blocks and extension methods.
- ReactiveUI-first β State as observables, commands for intents, no imperative event handlers.
- Cross-platform β Desktop, Android, iOS, and Browser from the same codebase.
Disclaimer
Zafiro.Avalonia is an independent community project and is not affiliated with, endorsed by, or sponsored by AvaloniaUI OΓ.
Avalonia is a trademark of AvaloniaUI OΓ.
License
Downloads by Version
Similar & Alternative Packages
Hand-picked matching NuGet libraries based on tags & ecosystem
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.