Prerequisites
- An SDK-style WPF project targeting
net8.0-windows10.0.19041.0ornet10.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)
| Option | Default | Notes |
|---|---|---|
Port | 9233 | Override with the AILOHA_PORT env var when launching multiple local fixtures. |
EnableBrokerRegistration | true | Registers with the broker on 19323 for CLI discovery. |
EnableProfiler | true | Enables desktop profiler endpoints. |
EnableNetworkCapture | true | Enables captured HTTP traffic APIs. |
EnableLogs | true | Captures console and file-backed logs. |
RouteResolver | null | Optional route navigation hook. |
BackHandler | null | Optional 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.