xaml-csharp-development-skill-for-avalonia

WPF to Avalonia Modern UI Conversion Index

Table of Contents

  1. Scope and Coverage Contract
  2. WPF 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 reference lane maps WPF application patterns to Avalonia 11.3.12 XAML/C# patterns for:

Coverage intent for this lane:

WPF Areas Mapped

Migration Workflow

  1. Port app lifetime and top-level window architecture.
  2. Port property system and reusable control contracts.
  3. Convert layouts and bindings to typed view-model patterns.
  4. Replace WPF trigger/visual-state usage with Avalonia selectors/pseudo-classes/transitions.
  5. Port commands/input, dialogs, and platform services.
  6. Port custom rendering/interop and harden with diagnostics + tests.

Granular Reference Set

Full API Coverage Pointers

For exhaustive lookup (not only migration samples):

First Conversion Example

WPF XAML:

<Button Content="Save"
        Command="{Binding SaveCommand}"
        Width="120"
        HorizontalAlignment="Right" />

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}"
          Width="120"
          HorizontalAlignment="Right" />
</UserControl>

WPF C#:

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

Avalonia C#:

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

AOT/Trimming and Threading Notes

Troubleshooting

  1. WPF visual-state-heavy templates do not map directly.
    • model states with pseudo-classes, classes, and transitions.
  2. command routing behavior differs.
    • register explicit KeyBinding and command scope on view roots.
  3. navigation assumptions from Frame/Page fail.
    • use view-model-driven region/content routing patterns.