Primary WinUI APIs:
Primary Avalonia APIs:
| WinUI idiom | Avalonia idiom |
|---|---|
| WinUI control/template/state pipeline | Avalonia control theme/style/selector pipeline |
x:Bind or {Binding} data flow |
{CompiledBinding ...} and typed x:DataType flow |
| WinUI layout/render invalidation model | Avalonia InvalidateMeasure/InvalidateArrange/InvalidateVisual model |
WinUI XAML:
<Page
x:Class="MyApp.Views.SamplePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp.Controls">
<Button Content="Save" Command="{x:Bind ViewModel.SaveCommand}"><Button.KeyboardAccelerators><KeyboardAccelerator Key="S" Modifiers="Control" /></Button.KeyboardAccelerators></Button>
</Page>
WinUI C#:
var view = new Button();
Avalonia XAML:
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:MyApp.ViewModels"
xmlns:local="using:MyApp.Controls"
x:DataType="vm:SampleViewModel">
<Button Content="Save" Command="{CompiledBinding SaveCommand}"><Button.KeyBindings><KeyBinding Gesture="Ctrl+S" Command="{CompiledBinding SaveCommand}" /></Button.KeyBindings></Button>
</UserControl>
Avalonia C#:
var save = new Button { Content = "Save", Command = viewModel.SaveCommand };