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.