### Install Declarative.Avalonia Templates Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/Templates/Declarative.Avalonia.Templates/README.md Run this command to install the project templates via the .NET CLI. ```bash dotnet new install Declarative.Avalonia.Templates ``` -------------------------------- ### Install and Create Project Template Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/readme.md Commands to install the project template and initialize a new Avalonia declarative application. ```bash dotnet new install Declarative.Avalonia.Templates dotnet new avalonia-declarative -n MyApp ``` -------------------------------- ### Configure MCP Client Connections Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/src/Declarative.Avalonia.AgentTools/README.md Configuration examples for connecting various MCP clients to the local inspector endpoint. ```bash claude mcp add --transport http avalonia-agent-inspector http://127.0.0.1:5599 ``` ```json // .mcp.json (project root) { "mcpServers": { "avalonia-agent-inspector": { "type": "http", "url": "http://127.0.0.1:5599" } } } ``` ```json // opencode.json { "$schema": "https://opencode.ai/config.json", "mcp": { "avalonia-agent-inspector": { "type": "remote", "url": "http://127.0.0.1:5599", "enabled": true } } } ``` ```toml # ~/.codex/config.toml [mcp_servers.avalonia-agent-inspector] url = "http://127.0.0.1:5599" # First time you use a streamable-HTTP MCP with Codex, enable the RMCP client once: [features] experimental_use_rmcp_client = true ``` -------------------------------- ### Example layout report output Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Displays the diagnostic output generated by the get_layout command for a Button control. ```text Button #Go Bounds: [x=8 y=34 w=48 h=32] (relative to parent) Window-rel: [x=8 y=34 w=48 h=32] (relative to Window 'Main') DesiredSize: 48 x 32 Requested: Width=Auto Height=Auto Min=(0,0) Max=(∞,∞) Alignment: Horizontal=Left Vertical=Center Margin: 0,0,0,0 Visibility: IsVisible=True IsEffectivelyVisible=True IsEnabled=True Opacity=1 ZIndex=0 Ancestors (root → control): Window #Main [x=0 y=0 w=400 h=300] StackPanel [x=0 y=0 w=400 h=300] Orientation=Vertical Button #Go [x=8 y=34 w=48 h=32] ``` -------------------------------- ### Agent Interaction Commands Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Examples of commands used to interact with UI elements through the agent inspector. ```text invoke "Exception sample" select # switch to the tab labeled "Exception sample" invoke "Save" invoke # click the Save button invoke "Remember me" toggle # flip a checkbox invoke "userName" set "alice" # set a TextBox value invoke "Animals" expand # expand a TreeViewItem by its header invoke "userName" key "Enter" # press Enter on a control (submit a form) invoke null type "hello" # type into whatever has focus invoke "themeCombo" select_item "Dark" # choose a ComboBox item by its text invoke "log" scroll_by "0,300" # scroll a ScrollViewer down by 300 ``` -------------------------------- ### Configure MCP Server for Agents Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/readme.md Configuration examples for connecting AI agents to the Avalonia agent inspector via HTTP. ```json { "mcpServers": { "avalonia-agent-inspector": { "type": "http", "url": "http://127.0.0.1:5599" } } } ``` ```json { "mcp": { "avalonia-agent-inspector": { "type": "remote", "url": "http://127.0.0.1:5599", "enabled": true } } } ``` ```toml [mcp_servers.avalonia-agent-inspector] url = "http://127.0.0.1:5599" ``` -------------------------------- ### Example of invoke_command failure output Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Shows the structured error message returned when a command path cannot be resolved. ```text invoke_command null "ViewCommands.ToggleBrushSettingsCommand" → path 'ViewCommands.ToggleBrushSettingsCommand' failed: DataContext is MainViewModel, no member 'ViewCommands'. Available ICommand properties: [SaveCommand, ToggleBrushSettingsCommand]. Sub-objects to drill into (dotted path): [AppState]. Did you mean 'ToggleBrushSettingsCommand'? Tip: call list_bindable to enumerate everything the target exposes. ``` -------------------------------- ### Define a Declarative Component Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/readme.md Example of a self-contained component using ViewBase and CommunityToolkit.Mvvm for reactive state management. ```csharp using Avalonia.Data; using CommunityToolkit.Mvvm.ComponentModel; public class CounterComponent() : ViewBase(new State()) { public sealed partial class State : ObservableObject { [ObservableProperty] [NotifyPropertyChangedFor(nameof(CounterLabel))] public partial decimal? Counter { get; set; } = 0; [ObservableProperty] public partial string StatusText { get; set; } = "Hello world"; public string CounterLabel => $"Counter: {Counter}"; } protected override object Build(State state) => new StackPanel() .Children( new TextBlock() .Text(state, x => x.StatusText), new TextBlock() .Text(state, x => x.CounterLabel), new NumericUpDown() .Value(state, x => x.Counter, BindingMode.TwoWay), new Button() .Content("Increment") .OnClick(_ => state.Counter++) ); } ``` -------------------------------- ### Common usage of view-model manipulation tools Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Demonstrates how to enumerate bindable properties, set view-model states, and invoke commands with or without parameters. ```text list_bindable # enumerate the main window VM's bindable surface set_view_model null IsBusy true # flip a flag on the main window's VM → spinner shows set_view_model "editor" Document.IsDirty true invoke_command null ShowRecoveryCommand # drive the app into the recovery state without a restart invoke_command "grid" RefreshCommand 25 # execute a command with a parameter ``` -------------------------------- ### Create a New Project Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/Templates/Declarative.Avalonia.Templates/README.md Use this command to scaffold a new Avalonia project named MyApp using the declarative template. ```bash dotnet new avalonia-declarative -n MyApp ``` -------------------------------- ### Configure opencode via opencode.json Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Add the server to the mcp key in the opencode configuration file. ```json // opencode.json { "$schema": "https://opencode.ai/config.json", "mcp": { "avalonia-agent-inspector": { "type": "remote", "url": "http://127.0.0.1:5599", "enabled": true } } } ``` -------------------------------- ### Implement MVVM with ViewBase Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/readme.md Use ViewBase to create views with compiled bindings in a fluent style. ```csharp using Avalonia.Data; public class MainView() : ViewBase(new MainViewModel()) { protected override object Build(MainViewModel vm) => new StackPanel() .Children( new TextBox() .Text(vm, x => x.Message, BindingMode.TwoWay), new TextBlock() .Text(vm, x => x.Message), new Button() .Content("Reset") .OnClick(_ => vm.Message = string.Empty) ); } ``` -------------------------------- ### Configure Codex via config.toml Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Add the server table to the Codex configuration file and enable the experimental RMCP client. ```toml # ~/.codex/config.toml [mcp_servers.avalonia-agent-inspector] url = "http://127.0.0.1:5599" # The first time you wire up a streamable-HTTP MCP, Codex needs its RMCP client enabled once: [features] experimental_use_rmcp_client = true ``` -------------------------------- ### Migrate component creation to ViewFactory Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/avalonia-12-release-notes.md Replace ComponentBase.New with ViewFactory.Create for view composition. ```csharp protected override object Build() => ComponentBase.New(); ``` ```csharp protected override object Build() => ViewFactory.Create(); ``` -------------------------------- ### set_window_size(width, height, windowId?) Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Resizes a desktop window to specific dimensions for screenshotting at breakpoints. Returns the resulting client size and the previous size. ```APIDOC ## set_window_size(width, height, windowId?) ### Description Resizes a desktop window to specific dimensions. Useful for capturing screenshots at specific breakpoints. ### Parameters - **width** (number) - Required - Target width in DIPs. - **height** (number) - Required - Target height in DIPs. - **windowId** (string/int) - Optional - Identifier for the target window. ``` -------------------------------- ### Capture and Scale UI Regions Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Use these commands to capture specific screen areas or resize window outputs for inspection. ```text screenshot_region 400 200 32 32 scale=8 # inspect a sprite pixel by pixel screenshot_window maxWidth=1280 # a cheap overview of a 4K window ``` -------------------------------- ### Open and Capture a Closed Popup Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Demonstrates how to detect a closed popup, open it using the name of the control, and then capture its content. ```text screenshot_control BrushSettingsPopup → 'BrushSettingsPopup' is a CLOSED popup … Open it first: open_popup{name:"BrushSettingsPopup"} … open_popup BrushSettingsPopup # sets IsOpen=true screenshot_control BrushSettings # now captures the realized content ``` -------------------------------- ### highlight Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Draws a visual frame around controls for debugging and returns a screenshot. ```APIDOC ## highlight(selector?, action?, color?) ### Description Draws a frame around matched controls in the adorner layer and returns a screenshot. Frames persist until cleared. ### Parameters - **selector** (string) - Optional - The control selector to highlight. - **action** (string) - Optional - Use 'clear' to remove all frames. - **color** (string) - Optional - The color of the frame (e.g., '#00A0FF' or 'Lime'). ``` -------------------------------- ### get_source Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Maps a live control back to its declarative component definition in the source code. ```APIDOC ## get_source(selector) ### Description Identifies the ViewBase subclass that created the live control. If EnableSourceTagging is enabled, it also provides the specific file and line number where the control was defined. ### Parameters - **selector** (string) - Required - The identifier for the live control to trace. ``` -------------------------------- ### Agent Tools Reference Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md A collection of tools for performing UI automation, input synthesis, and state management within an Avalonia application. ```APIDOC ## Agent Tools ### tap - **Description**: Performs a synthesized click (move, press, release) at an absolute client-DIP point. - **Arguments**: `x`, `y`, `button?`, `modifiers?`, `windowId?`, `count?`, `pointerType?`, `pressure?`, `inverted?` ### drag - **Description**: Performs a press-drag-release gesture. - **Arguments**: `x1`, `y1`, `x2`, `y2`, `button?`, `steps?`, `holdMs?`, `modifiers?`, `windowId?`, `pointerType?`, `pressure?`, `inverted?` ### pointer_press / pointer_move / pointer_release - **Description**: Executes low-level pointer steps. - **Arguments**: `x`, `y`, `button?`/`modifiers?`, `windowId?`, `pointerType?`, `pressure?`, `inverted?` ### pointer_wheel - **Description**: Simulates a wheel event at a specific point. - **Arguments**: `x`, `y`, `dx?`, `dy?`, `modifiers?`, `windowId?`, `precision?` ### touch_press / touch_move / touch_release - **Description**: Simulates touch contacts with explicit IDs. - **Arguments**: `touchId`, `x`, `y`, `pressure?`, `modifiers?`, `windowId?` ### pinch - **Description**: Performs a two-finger pinch/spread gesture. - **Arguments**: `cx`, `cy`, `fromDistance`, `toDistance`, `steps?`, `modifiers?`, `windowId?` ### invoke - **Description**: Remote control via UI Automation. - **Arguments**: `name?`, `action`, `value?` ### set_window_size - **Description**: Resizes a window to test responsive layout. - **Arguments**: `width`, `height`, `windowId?` ### set_theme - **Description**: Switches the application theme. - **Arguments**: `variant` ### click_at - **Description**: Clicks a control at a specific pixel. - **Arguments**: `x`, `y`, `windowId?`, `method?` ### open_popup - **Description**: Opens a closed Popup or Flyout. - **Arguments**: `name` ### set_view_model - **Description**: Sets a view-model property directly. - **Arguments**: `name?`, `path`, `value?` ### invoke_command - **Description**: Executes an ICommand or method on the view-model. - **Arguments**: `name?`, `path`, `parameter?` ``` -------------------------------- ### set_theme(variant) Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Sets the application theme variant and returns the actual applied theme. ```APIDOC ## set_theme(variant) ### Description Sets the `Application.RequestedThemeVariant` to the specified value and returns the resulting `ActualThemeVariant`. ### Parameters - **variant** (string) - Required - The theme variant to apply ('Light', 'Dark', or 'Default'). ``` -------------------------------- ### Configure Claude Code via .mcp.json Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Add the server configuration to a project-scoped .mcp.json file. ```json // .mcp.json (project root) { "mcpServers": { "avalonia-agent-inspector": { "type": "http", "url": "http://127.0.0.1:5599" } } } ``` -------------------------------- ### Registering Custom Tools Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Register custom tool classes with the agent inspector using WithTools and define tool methods with McpServerTool attributes. ```csharp [McpServerToolType] public sealed class SpriteTools { private readonly AppState _state; public SpriteTools(AppState state) => _state = state; [McpServerTool(Name = "get_sprite_info", ReadOnly = true), Description( "Returns the open sprite's size, frame count and the selected layer.")] public string GetSpriteInfo() => $"{_state.Sprite.Size}, {_state.Sprite.Frames.Count} frame(s), layer '{_state.SelectedLayer.Name}'"; } .UseAgentInspector(o => { o.EnableInteraction = true; o.Services = serviceProvider; // your app's container o.WithTools(); }) ``` ```csharp [McpServerToolType] [AgentInteractionTools] // registered only when EnableInteraction is set public sealed class SpriteEditTools { /* … */ } ``` -------------------------------- ### Configure Source Generator via ProjectReference Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/readme.md Add the source generator as an analyzer reference when using the library from source code. ```xml ``` -------------------------------- ### Migrate MVU component to stateful declarative view Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/avalonia-12-release-notes.md Transition from ComponentBase to ViewBase with an ObservableObject state class to leverage compiled bindings. ```csharp public class CounterComponent : ComponentBase { public decimal? Counter { get; set; } protected override object Build() => new StackPanel() .Children( new TextBlock() .Text(() => $"Counter: {Counter}"), new Button() .Content("Increment") .OnClick(_ => { Counter++; StateHasChanged(); }) ); } ``` ```csharp using CommunityToolkit.Mvvm.ComponentModel; public partial class CounterComponent() : ViewBase(new State()) { protected override object Build(State state) => new StackPanel() .Children( new TextBlock() .Text(state, x => x.CounterLabel), new Button() .Content("Increment") .OnClick(_ => state.Counter++) ); public sealed partial class State : ObservableObject { [ObservableProperty] [NotifyPropertyChangedFor(nameof(CounterLabel))] public partial decimal? Counter { get; set; } = 0; public string CounterLabel => Counter is null || Counter == 0 ? "Counter: zero" : $"Counter: {Counter}"; } } ``` -------------------------------- ### Simulate Wheel and Touchpad Input Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Generate wheel events with specific deltas, modifiers, or precision touchpad emulation. ```text pointer_wheel 640 400 dy=3 # zoom in three notches at the cursor pointer_wheel 640 400 dy=-1 modifiers=Ctrl pointer_wheel 640 400 dy=1 precision=true # same amount, as a touchpad burst ``` -------------------------------- ### Synthesize Pointer Input Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Basic pointer operations for clicking and dragging at absolute coordinates. ```text tap 128 96 # real click at an absolute point drag 40 300 210 300 # scrub a custom slider left→right pointer_press 40 300 ; pointer_move 210 300 ; pointer_release 210 300 ``` -------------------------------- ### Configure Agent Inspector Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/readme.md Integrate the MCP server for AI agent tooling within debug builds using the UseAgentInspector extension. ```csharp using Declarative.Avalonia.AgentTools; // under #if DEBUG AppBuilder.Configure() .UsePlatformDetect() #if DEBUG .UseAgentInspector() // loopback MCP server on 127.0.0.1:5599 #endif .SetupWithLifetime(lifetime); ``` -------------------------------- ### invoke_command(name?, path, parameter?) Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Executes an ICommand at the specified path or invokes a public method. It checks CanExecute before execution. ```APIDOC ## invoke_command(name?, path, parameter?) ### Description Executes an ICommand at the specified path or invokes a public method. It checks CanExecute before execution. ### Parameters - **name** (string) - Optional - The control name or label whose DataContext is used. If omitted, the main window's DataContext is used. - **path** (string) - Required - The dotted path to the ICommand or public method. - **parameter** (any) - Optional - The argument to pass to the command or method. ``` -------------------------------- ### Register Claude Code via CLI Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Use the command line to register the MCP server for Claude Code. ```bash claude mcp add --transport http avalonia-agent-inspector http://127.0.0.1:5599 ``` -------------------------------- ### Register Custom Tools and Inspector Options Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/src/Declarative.Avalonia.AgentTools/README.md Define custom tools using attributes and register them via the UseAgentInspector options delegate. ```csharp [McpServerToolType] public sealed class SpriteTools(AppState state) { [McpServerTool(Name = "get_sprite_info", ReadOnly = true), Description( "Returns the open sprite's size, frame count and the selected layer.")] public string GetSpriteInfo() => $"{state.Sprite.Size}, {state.Sprite.Frames.Count} frame(s)"; } .UseAgentInspector(o => { o.EnableInteraction = true; o.Services = serviceProvider; o.WithTools(); }) ``` -------------------------------- ### Tool Definitions Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md A collection of tools for inspecting the visual tree, layout, properties, and state of an Avalonia application. ```APIDOC ## Tool Reference ### Orient & Inspect Tools - **get_app_info**: Returns app metadata, window state, and theme. - **get_visual_tree**: Returns the visual tree structure with absolute coordinates. - **get_layout**: Retrieves detailed layout information for a specific control. - **get_properties**: Returns effective state and property values for a control. - **get_property_sources**: Identifies the source of a property value. - **get_data_context**: Returns the view-model rendered as text. - **get_source**: Retrieves the ViewBase component that built the control. - **find_text**: Searches for controls containing specific visible text. - **hit_test**: Identifies the control chain at specific coordinates. - **list_components**: Lists active declarative views. - **list_bindable**: Discovers bindable properties and commands. ### Verify Tools - **layout_audit**: Performs automated layout linting. - **screenshot_window**: Captures a PNG of a window. - **screenshot_control**: Captures a PNG of a specific control. - **screenshot_region**: Captures a PNG of an arbitrary rectangle. - **highlight**: Draws a frame around matches and returns a screenshot. - **compare_screenshots**: Performs pixel-diffing between two captures. - **list_screenshots**: Lists recent screenshot identifiers. - **wait_for**: Waits for a specific condition to be met. - **wait_idle**: Waits for the UI thread to drain. - **get_errors**: Retrieves recent runtime and binding errors. - **get_logs**: Retrieves raw application log output. - **get_render_stats**: Returns performance metrics like FPS and layout duration. ``` -------------------------------- ### MCP Tool Interface Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/src/Declarative.Avalonia.AgentTools/README.md The library exposes a set of MCP tools for inspecting and controlling an Avalonia application. These tools are categorized into inspection, screenshotting, and interaction capabilities. ```APIDOC ## MCP Tool Reference ### Inspection Tools - `get_app_info`: Retrieves window, focus, popup, theme, and hot-reload state. - `get_visual_tree`: Returns the visual tree with names, bounds, and absolute coordinates. - `get_layout`: Provides detailed layout info for a control (bounds, padding, margin, etc.). - `get_properties`: Returns effective state and locally-set styled properties. - `get_property_sources`: Identifies the source of property values (local, style, template, etc.). - `get_data_context`: Returns the control's view-model as text. - `get_source`: Returns the ViewBase component class and file/line info. - `find_text` / `hit_test`: Locates controls by text or pixel coordinates. - `layout_audit`: Performs automated layout linting. - `list_components`: Lists active declarative views. - `get_errors`: Retrieves recent build, binding, or runtime errors. - `get_logs`: Fetches raw application log output. - `get_render_stats`: Provides performance metrics (FPS, layout duration, visual count). ### Screenshot Tools - `screenshot_window` / `screenshot_control` / `screenshot_region`: Captures PNG screenshots with optional annotation, scaling, and cropping. - `compare_screenshots` / `list_screenshots`: Performs pixel-based diffing. ### Interaction Tools - `tap`, `drag`, `pointer_*`, `touch_*`, `pinch`: Synthesizes input through the Avalonia pipeline. - `invoke`, `set_window_size`, `set_theme`, `click_at`, `open_popup`, `list_bindable`, `set_view_model`, `invoke_command`: Remote control operations for UI manipulation and state modification. ``` -------------------------------- ### Compare Screenshots Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Compares two captured screenshots to generate a diff image and pixel change statistics. Omit IDs to compare the two most recent captures. ```text screenshot_window # → id=s1 (before) # … change code, hot reload, wait_idle … screenshot_window # → id=s2 (after) compare_screenshots # diff s1 → s2 ``` -------------------------------- ### Use BindingBase for Advanced Scenarios Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/readme.md Use BindingBase overloads when you need reflection bindings, MultiBindings, or specific source configurations that aren't covered by expression-based bindings. ```csharp using Avalonia.Data; new TextBlock() .Text(new Binding("ReflectionProperty")) // DataContext-relative reflection binding .Foreground(new Binding("Theme.Accent") { Source = appState }); // explicit source new TextBlock() .Text(CompiledBinding.Create(x => x.Title, source: vm)); // attached properties and styles get the same overload new Border().Grid_Row(new Binding(nameof(vm.Row)) { Source = vm }); new Style().Text(new Binding(nameof(vm.Name))); ``` -------------------------------- ### Configure Agent Inspector via Project File Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Conditionally reference the AgentTools project in the debug configuration of your project file. ```xml ``` -------------------------------- ### Highlight UI elements for debugging Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Draws frames around controls for visual verification. Use 'clear' to remove overlays. ```text highlight Go # frame the Go button, return a screenshot showing it highlight Button color Lime # frame every Button in lime highlight null clear # remove all frames ``` -------------------------------- ### click_at(x, y, windowId?, method?) Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Performs a click at specific absolute client-DIP coordinates, useful for custom-drawn controls. ```APIDOC ## click_at(x, y, windowId?, method?) ### Description Clicks at a specific pixel coordinate. Defaults to synthesizing a real pointer click, with fallback to UI-Automation. ### Parameters - **x** (number) - Required - Absolute client-DIP X coordinate. - **y** (number) - Required - Absolute client-DIP Y coordinate. - **windowId** (string/int) - Optional - Identifier for the target window. - **method** (string) - Optional - Interaction method: 'auto' (default), 'pointer' (forces real pointer), or 'automation' (forces UI-Automation path). ``` -------------------------------- ### invoke Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Dispatches actions to UI controls using Avalonia's UI Automation peers. This tool is off by default and requires EnableInteraction to be set to true. ```APIDOC ## invoke(name?, action, value?) ### Description Executes an action on a UI control identified by its name or label. It uses UI Automation patterns to interact with controls like buttons, text boxes, and tree views. ### Parameters - **name** (string) - Optional - The name or label of the target control. - **action** (string) - Required - The action to perform (e.g., 'invoke', 'select', 'toggle', 'set', 'expand', 'collapse', 'focus', 'scroll', 'context_menu', 'key', 'type'). - **value** (string) - Optional - The value associated with the action (e.g., text for 'type', key gesture for 'key', or numeric values for 'set'). ``` -------------------------------- ### Customize Agent Inspector Options Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Pass an options delegate to UseAgentInspector to customize settings like the port or interaction capabilities. ```csharp .UseAgentInspector(o => { o.Port = 5599; o.EnableInteraction = false; // keep off unless you really need it }) ``` -------------------------------- ### Retrieve layout report for a control Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Executes a layout inspection for a control identified by the selector 'Go'. ```text get_layout Go ``` -------------------------------- ### list_bindable(name?) Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/agent-tools.md Enumerates the bindable surface of the target DataContext, including settable properties, ICommands, invokable methods, and sub-objects. ```APIDOC ## list_bindable(name?) ### Description Enumerates the bindable surface of the target DataContext, including settable properties, ICommands, invokable methods, and sub-objects. ### Parameters - **name** (string) - Optional - The control name or label whose DataContext is used. If omitted, the main window's DataContext is used. ``` -------------------------------- ### Migrate external CLI generator to integrated source generator Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/docs/avalonia-12-release-notes.md Use the assembly attribute for generating markup extensions instead of an external CLI tool. ```bash dotnet tool install --global AvaloniaExtensionGenerator cd c:\your\project avalonia-amd-gen ``` ```csharp using Avalonia.Markup.Declarative; using ReactiveUI.Avalonia; [assembly: GenerateMarkupExtensionsForAssembly(typeof(RoutedViewHost))] ``` -------------------------------- ### Equivalent XAML View Source: https://github.com/avaloniacommunity/avalonia.markup.declarative/blob/master/readme.md Standard XAML representation of the MVVM view implemented in the previous snippet. ```xml