Primary WinForms APIs:
AutoScaleModeDpiChanged eventsRightToLeftPrimary Avalonia APIs:
TopLevel.RenderScalingTopLevel.ScalingChangedFlowDirection (LeftToRight, RightToLeft)| WinForms | Avalonia |
|---|---|
AutoScaleMode.Dpi |
platform-managed scaling with logical units |
Form.DpiChanged |
TopLevel.ScalingChanged |
| manual pixel math | rely on device-independent units, convert only at interop boundaries |
| WinForms | Avalonia |
|---|---|
RightToLeft = Yes |
FlowDirection="RightToLeft" |
| mixed-direction forms | set FlowDirection at subtree scope |
WinForms C#:
AutoScaleMode = AutoScaleMode.Dpi;
RightToLeft = RightToLeft.Yes;
DpiChanged += (_, e) =>
{
statusLabel.Text = $"DPI changed: {e.DeviceDpiNew}";
};
Avalonia XAML:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:MyApp.ViewModels"
x:DataType="vm:MainViewModel"
FlowDirection="RightToLeft"
Width="800"
Height="480">
<StackPanel Margin="12" Spacing="8">
<TextBlock Text="{CompiledBinding ScalingText}" />
<TextBox Watermark="Name" />
</StackPanel>
</Window>
using Avalonia.Controls;
using Avalonia.Media;
public static void AttachScalingListener(Window window, MainViewModel viewModel)
{
window.FlowDirection = FlowDirection.RightToLeft;
viewModel.ScalingText = $"Scale: {window.RenderScaling:0.00}";
window.ScalingChanged += (_, _) =>
{
viewModel.ScalingText = $"Scale: {window.RenderScaling:0.00}";
};
}
FlowDirection on the correct subtree root.