Expert guidance for developing cross-platform desktop applications with Avalonia UI framework...
Modular guidance for cross-platform desktop and mobile development using Avalonia, a WPF-inspired XAML-based framework for .NET.
| Task/Goal | Load Resource |
|---|---|
| MVVM patterns, data binding, dependency injection, value converters | resources/mvvm-databinding.md |
| UI controls reference (layouts, inputs, collections, menus) | resources/controls-reference.md |
| Custom controls, advanced layouts, performance optimization, virtualization | resources/custom-controls-advanced.md |
| Styling, themes, animations, control templates | resources/styling-guide.md |
| Reactive patterns, commands, observables, animations | resources/reactive-animations.md |
| Windows, macOS, Linux, iOS, Android implementation details | resources/platform-specific.md |
Avalonia is a cross-platform XAML framework supporting:
MyAvaloniaApp/
├── MyAvaloniaApp/ # Shared code
│ ├── App.axaml
│ ├── Views/ # XAML views
│ ├── ViewModels/ # Business logic + state
│ ├── Models/ # Data models
│ ├── Services/ # Application services
│ ├── Converters/ # Value converters
│ ├── Assets/ # Images, fonts
│ └── Styles/ # Style resources
├── MyAvaloniaApp.Desktop/ # Desktop-specific (Win/Mac/Linux)
├── MyAvaloniaApp.Android/ # Android-specific (optional)
├── MyAvaloniaApp.iOS/ # iOS-specific (optional)
└── MyAvaloniaApp.Browser/ # WebAssembly (optional)
// Program.cs
public static void Main(string[] args)
{
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace();
<!-- App.axaml -->
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MyApp.App">
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
<!-- Views/MainWindow.axaml -->
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MyApp.Views.MainWindow"
Title="My Application"
Width="800"
Height="600">
<StackPanel Padding="20" Spacing="10">
<TextBlock Text="Hello, Avalonia!" FontSize="24" FontWeight="Bold" />
</StackPanel>
</Window>
Load resources/mvvm-databinding.md for:
Leverage ReactiveUI for event-driven UI updates:
this.WhenAnyValue(x => x.SearchText)
.Debounce(TimeSpan.FromMilliseconds(300))
.Subscribe(text => PerformSearch(text));
Load resources/reactive-animations.md for:
Design once, adapt per platform:
<OnPlatform Default="16">
<On Options="Windows" Content="14" />
<On Options="macOS" Content="15" />
</OnPlatform>
Load resources/platform-specific.md for:
resources/mvvm-databinding.md → Implement ViewModel with property validationresources/controls-reference.md → Find TextBox, ComboBox, Button controlsresources/reactive-animations.md → Add debounced validation with observablesresources/custom-controls-advanced.md → Enable virtualizationresources/mvvm-databinding.md → Use compiled bindingsresources/reactive-animations.md → Debounce/throttle updatesresources/platform-specific.md → Implement service interfacesresources/mvvm-databinding.md → Register platform implementations via DIresources/ → Implement per-platform projectresources/styling-guide.md → Define styles and themesresources/reactive-animations.md → Add animations to stylesresources/custom-controls-advanced.md → Custom control templatesresources/custom-controls-advanced.md → TemplatedControl or UserControl patternresources/mvvm-databinding.md → Attached properties and data bindingresources/styling-guide.md → Control templates and stylingmvvm-databinding.md (Primary)controls-reference.md (Primary)styling-guide.md (Primary)reactive-animations.md (Advanced)custom-controls-advanced.md (Advanced)platform-specific.md (Advanced)1. → Setup: Standard project structure + FluentTheme
2. → Create Views and ViewModels following MVVM
3. → Use controls-reference for UI layouts
4. → Add styles with styling-guide
5. → Implement services with DI (mvvm-databinding)
6. → Add animations with reactive-animations
7. → Test on each platform with platform-specific guidance
1. → Create shared project + platform-specific projects
2. → Define service interfaces in shared code (mvvm-databinding)
3. → Implement services per platform (platform-specific)
4. → Use OnPlatform for adaptive UI
5. → Register platform implementations via DI
6. → Test thoroughly on each target (iOS/Android/Windows/Mac)
1. → Create SearchViewModel (mvvm-databinding)
2. → Use ObservableCollection for results (mvvm-databinding)
3. → Implement with reactive search pattern (reactive-animations)
4. → Debounce input to reduce API calls
5. → Display with ListBox (controls-reference)
6. → Style with appropriate CSS selectors (styling-guide)
1. → Design ViewModel hierarchy (mvvm-databinding)
2. → Create master-detail view (mvvm-databinding)
3. → Use DataGrid for tabular data (controls-reference)
4. → Add sorting/filtering with observables (reactive-animations)
5. → Optimize with virtualization (custom-controls-advanced)
6. → Add custom controls if needed (custom-controls-advanced)
Architecture
Performance
x:DataTypeStyling
Reactive Patterns
Testing
Refer to resources/platform-specific.md for platform-specific build and deployment guidance.
Navigation: Choose a resource above based on your task. Each resource is self-contained with comprehensive examples and best practices.