Primary WPF APIs:
Grid, StackPanel, DockPanel, WrapPanel, CanvasMeasureOverride, ArrangeOverridePrimary Avalonia APIs:
Grid, StackPanel, DockPanel, WrapPanel, Canvas)MeasureOverride, ArrangeOverrideTopLevel.RenderScaling and logical-unit layout| WPF | Avalonia |
|---|---|
Grid.RowDefinitions/ColumnDefinitions |
same concept and syntax |
DockPanel.Dock |
same concept |
HorizontalAlignment/VerticalAlignment |
same concept |
UseLayoutRounding tuning |
rely on logical units, tune rendering only where needed |
WPF custom panel logic generally ports 1:1 conceptually:
WPF XAML:
<Grid Margin="12" RowDefinitions="Auto,*" ColumnDefinitions="200,*">
<TextBlock Grid.Row="0" Grid.Column="0" Text="Name" />
<TextBox Grid.Row="0" Grid.Column="1" />
</Grid>
Avalonia XAML:
<Grid Margin="12" RowDefinitions="Auto,*" ColumnDefinitions="200,*">
<TextBlock Grid.Row="0" Grid.Column="0" Text="Name" />
<TextBox Grid.Row="0" Grid.Column="1" />
</Grid>
using Avalonia.Controls;
var form = new Grid
{
Margin = new Avalonia.Thickness(12),
RowDefinitions = RowDefinitions.Parse("Auto,*"),
ColumnDefinitions = ColumnDefinitions.Parse("200,*")
};
form.Children.Add(new TextBlock { Text = "Name" });
var name = new TextBox();
Grid.SetColumn(name, 1);
form.Children.Add(name);
InvalidateMeasure/InvalidateArrange).RenderScaling only when needed.