xaml-csharp-development-skill-for-avalonia

WinUI to Avalonia Modern UI Conversion Index

Table of Contents

  1. Scope and Coverage Contract
  2. WinUI Areas Mapped
  3. Migration Workflow
  4. Granular Reference Set
  5. Full API Coverage Pointers
  6. First Conversion Example
  7. AOT/Trimming and Threading Notes
  8. Troubleshooting

Scope and Coverage Contract

This lane maps WinUI (Windows App SDK / WinUI 3) app patterns to Avalonia 11.3.12 XAML/C# patterns.

Coverage focuses on:

WinUI Areas Mapped

Migration Workflow

  1. Port shell/lifetime first.
  2. Port navigation and command surfaces.
  3. Convert bindings/resources/templates/states.
  4. Port control families and dialogs.
  5. Port layout and rendering hot paths.
  6. Verify accessibility, testing, and performance parity.

Granular Reference Set

All detailed WinUI conversion references live under winui-to-avalonia/README.md:

Full API Coverage Pointers

For exhaustive lookup (not only migration samples):

First Conversion Example

WinUI XAML:

<Button Content="Save"
        Command="{x:Bind ViewModel.SaveCommand}" />

Avalonia XAML:

<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:MyApp.ViewModels"
             x:DataType="vm:MainViewModel">
  <Button Content="Save"
          Command="{CompiledBinding SaveCommand}" />
</UserControl>

WinUI C# (dependency property):

public static readonly DependencyProperty TitleProperty =
    DependencyProperty.Register(nameof(Title), typeof(string), typeof(HeaderCard), new PropertyMetadata(""));

Avalonia C#:

public static readonly StyledProperty<string> TitleProperty =
    AvaloniaProperty.Register<HeaderCard, string>(nameof(Title), string.Empty);

AOT/Trimming and Threading Notes

Troubleshooting

  1. Visual states don’t map directly.
    • Model state via classes/pseudo-classes and transitions.
  2. Navigation shell behavior diverges.
    • Move to explicit view-model routing and content-host composition.
  3. Rendering loops are expensive after migration.
    • Use transitions/compositor animations first, custom draw only where necessary.