ailoha.
Home/ Docs/ WPF

Manual setup — WPF

A first-class WPF agent for SDK-style Windows desktop apps. It walks the visual tree, captures screenshots, supports WebView2 diagnostics, and registers with the Ailoha broker.

Package Ailoha.Agent.Wpf Default port 9233 .NET 8 / 10 Sample wpf/samples/Ailoha.Wpf.Sample

Prerequisites

  • An SDK-style WPF project targeting net8.0-windows10.0.19041.0 or net10.0-windows10.0.19041.0.
  • The Ailoha CLI installed: see install instructions.
  • Windows 10 19041+ or Windows 11 with an interactive desktop session.

1. Install the package

dotnet add package Ailoha.Agent.Wpf

Or in your .csproj:

<PackageReference Include="Ailoha.Agent.Wpf" Version="0.1.*" />

When developing Ailoha itself from a local checkout, reference the agent project directly instead of the NuGet package:

<ProjectReference Include="C:\path\to\ailoha\wpf\agent\Ailoha.Agent.Wpf\Ailoha.Agent.Wpf.csproj" />

2. Start the agent

Start the agent from your main window after WPF has initialized and rendered the window. Wrap it in #if DEBUG or another internal-only guard:

using Ailoha.Agent.Wpf;
using System.Windows;

public partial class MainWindow : Window
{
    private WpfDevFlowAgent? _agent;

    public MainWindow()
    {
        InitializeComponent();
    }

    protected override void OnContentRendered(EventArgs e)
    {
        base.OnContentRendered(e);

#if DEBUG
        _agent ??= WpfDevFlowAgent.Start(this, options =>
        {
            options.AppName = "My WPF App";
            options.RouteResolver = route => false;
            options.BackHandler = () => false;
        });
#endif
    }
}

3. Configure (optional)

OptionDefaultNotes
Port9233Override with the AILOHA_PORT env var when launching multiple local fixtures.
EnableBrokerRegistrationtrueRegisters with the broker on 19323 for CLI discovery.
EnableProfilertrueEnables desktop profiler endpoints.
EnableNetworkCapturetrueEnables captured HTTP traffic APIs.
EnableLogstrueCaptures console and file-backed logs.
RouteResolvernullOptional route navigation hook.
BackHandlernullOptional back action hook.

4. Use stable automation IDs

Use WPF automation properties for controls you want agents to query or interact with:

<Button Content="Save"
        AutomationProperties.AutomationId="SaveEntryButton" />

5. Run and verify

Launch the app in Debug mode, then check broker discovery and a shallow tree:

ailoha agent wait --timeout 60
ailoha agent status
ailoha ui tree --depth 2

If you are debugging Ailoha from source, run the local CLI assembly so the app and CLI use the same checkout:

$AilohaRoot = "C:\path\to\ailoha"
dotnet "$AilohaRoot\tool\src\Ailoha.CLI\bin\Debug\net10.0\ailoha.dll" agent status

What's next

  • See the WinUI guide for the closest native Windows companion surface.
  • Run the verification commands above after wiring the package into your app.