MAUI
Register the MAUI tool suite to inspect and drive active .NET MAUI UI state, including pages, visual trees, elements, XAML experiments, themes, bindings, resources, navigation, layout, handlers, bindable properties, and binding contexts.
Warning: This suite can reveal live UI state, binding expressions, resource dictionaries, handler metadata, and binding-context objects. It also includes Write tools that mutate bindable properties, inflate and attach XAML, change the app theme, invoke commands, drive UI actions, and update view-model properties. Keep it limited to local development builds and use the narrowest guard level that supports the workflow.
Install
For a MAUI app that wants the standard setup, install the all-in-one MAUI package:
dotnet add package Ansight.Maui --prerelease
Install the tool package directly only when you are using Ansight.Core and registering tool suites yourself:
dotnet add package Ansight.Tools.Maui --prerelease
Register the Suite
using Ansight;
using Ansight.Tools.Maui;
var options = Options.CreateBuilder()
.WithMauiTools()
.WithReadWriteToolAccess()
.Build();
Use WithReadOnlyToolAccess() for page, tree, element, binding, resource, navigation, layout, handler, and binding-context inspection. Use WithReadWriteToolAccess() only when a workflow needs mutation, XAML experiments, app theme changes, or app-code invocation.
Registration API
WithMauiTools(): registers the full .NET MAUI tool suite. No suite-specific configuration is currently required.
Specific Concerns
- The suite runs on the MAUI main thread and inspects the active MAUI
Applicationwindow. maui.get_visual_treeandmaui.find_elementsreturn MAUI element ids that can be passed to focused element, property, binding, layout, handler, action, wait, XAML experiment, and binding-context tools.- Element ids are runtime ids. Prefer
AutomationIdwhen you need stable lookup across sessions. maui.get_bindable_property,maui.get_bindings, andmaui.get_binding_contextcan reveal user-entered text and app state.maui.get_resource_statecan reveal resource keys and, when requested, shallow resource values.maui.invoke_element_actionandmaui.invoke_binding_context_commandcan execute app code.maui.inflate_xamlcreates detached MAUI elements from arbitrary XAML. Usemaui.add_elementandmaui.remove_elementto attach or detach those elements.maui.set_app_themechangesApplication.Current.UserAppThemeat runtime.maui.set_bindable_property,maui.clear_bindable_property,maui.add_element,maui.remove_element,maui.set_app_theme, andmaui.set_binding_context_propertymutate live UI, theme, or view-model state.- The suite is supported on Android, iOS, and Mac Catalyst MAUI targets.
Tool Matrix
| Name | Id | Scope | Description | Security |
|---|---|---|---|---|
Get Current MAUI Page | maui.get_current_page | Read | Returns the currently displayed .NET MAUI page and navigation metadata. | High |
Get MAUI Visual Tree | maui.get_visual_tree | Read | Returns the live .NET MAUI visual tree for the active window or page. | High |
Find MAUI Elements | maui.find_elements | Read | Searches the live visual tree by node id, AutomationId, type, label, state, binding-context type, or bindable property. | High |
Get MAUI Element | maui.get_element | Read | Returns a focused snapshot for one element, including path, children, properties, bindable properties, and binding-context type. | High |
Get MAUI Bindable Property | maui.get_bindable_property | Read | Reads a bindable property from a node in the current visual tree. | High |
Set MAUI Bindable Property | maui.set_bindable_property | Write | Writes a bindable property on a node in the current visual tree. | Critical |
Clear MAUI Bindable Property | maui.clear_bindable_property | Write | Clears a local bindable-property value, binding, or both. | Critical |
Inflate XAML | maui.inflate_xaml | Write | Inflates arbitrary .NET MAUI XAML into a retained runtime element. | Critical |
Add Element | maui.add_element | Write | Adds an inflated or existing .NET MAUI element to the live visual tree. | Critical |
Remove Element | maui.remove_element | Write | Removes an inflated or existing .NET MAUI element from the live visual tree. | Critical |
Set App Theme | maui.set_app_theme | Write | Changes the live .NET MAUI application theme override. | Critical |
Get MAUI Binding Context | maui.get_binding_context | Read | Returns binding-context metadata and optional public property snapshots. | Critical |
Get MAUI Bindings | maui.get_bindings | Read | Enumerates active bindings on a node and optionally includes current target values. | Critical |
Get MAUI Resource State | maui.get_resource_state | Read | Inspects app, window, page, ancestor, or element resource dictionaries. | High |
Get MAUI Navigation State | maui.get_navigation_state | Read | Returns active window, page, navigation stack, modal stack, and Shell metadata. | High |
Invoke MAUI Element Action | maui.invoke_element_action | Write | Invokes controlled user-like actions or commands on an element. | Critical |
Wait For MAUI UI | maui.wait_for_ui | Read | Polls until an element, page, property, or binding-context condition is met. | High |
Get MAUI Layout Diagnostics | maui.get_layout_diagnostics | Read | Returns layout measurements, attached layout values, visibility, and input diagnostics. | High |
Get MAUI Handler Diagnostics | maui.get_handler_diagnostics | Read | Returns handler and platform-view metadata for one element. | High |
Invoke MAUI Binding Context Command | maui.invoke_binding_context_command | Write | Invokes an ICommand on an element binding context. | Critical |
Set MAUI Binding Context Property | maui.set_binding_context_property | Write | Writes a public property on an element binding context. | Critical |
Core Inspection
Get Current MAUI Page
Arguments: none.
Returns platform, capturedAtUtc, windowCount, window, rootPage, currentPage, and navigation.
{
"toolId": "maui.get_current_page",
"arguments": {}
}
Get MAUI Visual Tree
Arguments:
root:currentPage,rootPage, orwindow; defaultcurrentPagerootNodeId: optional node id or AutomationId to use as the subtree rootincludeBounds: include MAUI layout bounds; defaulttrueincludeProperties: include common element properties; defaultfalseincludeBindableProperties: include bindable-property metadata; defaultfalseincludeBindingContexts: include binding-context type metadata; defaultfalsemaxDepth: child depth limit; default8maxNodes: maximum nodes before truncation; default500
{
"toolId": "maui.get_visual_tree",
"arguments": {
"root": "currentPage",
"includeBounds": true,
"includeBindingContexts": true,
"maxDepth": 6
}
}
Find MAUI Elements
Searches without returning the whole tree.
Common filters:
nodeId,automationId,styleId,classIdtypeName,kind,labelContains,bindingContextTypeNamevisible,enabledpropertyNameand optionalpropertyValueJsonroot,rootNodeId,maxDepth,maxResults
{
"toolId": "maui.find_elements",
"arguments": {
"automationId": "LoginEmailEntry",
"includeBounds": true
}
}
Get MAUI Element
Arguments:
nodeId: required node id or AutomationIdincludeBounds,includeProperties,includeBindableProperties,includeBindingContext,includeChildren
{
"toolId": "maui.get_element",
"arguments": {
"nodeId": "LoginEmailEntry",
"includeBindableProperties": true
}
}
Bindable Properties
Get Bindable Property
Arguments:
nodeId: required node id or AutomationIdpropertyName: required bindable property name, such asTextorTextPropertydeclaringTypeName: optional declaring type name
{
"toolId": "maui.get_bindable_property",
"arguments": {
"nodeId": "LoginEmailEntry",
"propertyName": "Text"
}
}
Set Bindable Property
Arguments:
nodeId: required node id or AutomationIdpropertyName: required bindable property namedeclaringTypeName: optional declaring type namevalueJson: required new value encoded as JSON
{
"toolId": "maui.set_bindable_property",
"arguments": {
"nodeId": "LoginEmailEntry",
"propertyName": "Text",
"valueJson": "\"person@example.com\""
}
}
Clear Bindable Property
Arguments:
nodeId: required node id or AutomationIdpropertyName: required bindable property namedeclaringTypeName: optional declaring type namemode:value,binding, orboth; defaultboth
{
"toolId": "maui.clear_bindable_property",
"arguments": {
"nodeId": "StatusLabel",
"propertyName": "Text",
"mode": "both"
}
}
Runtime UI Mutation
Inflate XAML
Arguments:
xaml: required MAUI XAML markup to inflate withLoadFromXamlrootTypeName: optional CLR type name to instantiate before loading XAML
Returns a retained detached element id that can be passed to maui.add_element.
{
"toolId": "maui.inflate_xaml",
"arguments": {
"xaml": "<Label xmlns=\"http://schemas.microsoft.com/dotnet/2021/maui\" Text=\"Experiment\" />"
}
}
Add Element
Arguments:
parentNodeId: required live parent node id or AutomationIdelementNodeId: required node id returned bymaui.inflate_xaml, a live node id, or an AutomationIdindex: optional insertion index for layout childrenreplaceContent: replace an existingContentvalue when adding to a content control; defaultfalsedetachFromCurrentParent: detach the element from its current parent before adding it; defaultfalse
{
"toolId": "maui.add_element",
"arguments": {
"parentNodeId": "ExperimentHost",
"elementNodeId": "82c2f357a0a64d5f9e6f1cb3b47e7b24",
"detachFromCurrentParent": true
}
}
Remove Element
Arguments:
nodeId: required node id returned by the visual tree,maui.inflate_xaml, or an AutomationIdforget: forget a retained inflated element after detaching it; defaultfalse
{
"toolId": "maui.remove_element",
"arguments": {
"nodeId": "82c2f357a0a64d5f9e6f1cb3b47e7b24",
"forget": true
}
}
Set App Theme
Arguments:
theme: requiredsystem,light, ordark;systemclears the override and follows the device/app default
The tool sets Application.Current.UserAppTheme and returns the previous and current UserAppTheme and effective RequestedTheme values.
{
"toolId": "maui.set_app_theme",
"arguments": {
"theme": "dark"
}
}
Binding Diagnostics
Get Binding Context
Arguments:
nodeId: required node id or AutomationIdincludeProperties: include public property snapshots; defaultfalsemaxDepth: object graph depth limit; default1, maximum4maxProperties: public property limit per object; default32
{
"toolId": "maui.get_binding_context",
"arguments": {
"nodeId": "LoginPage",
"includeProperties": true,
"maxDepth": 1
}
}
Get MAUI Bindings
Arguments:
nodeId: required node id or AutomationIdpropertyName: optional bindable property nameincludeUnbound: include properties without active bindings; defaultfalseincludeValues: include current target values; defaultfalsemaxProperties: maximum bindable properties to inspect; default32
{
"toolId": "maui.get_bindings",
"arguments": {
"nodeId": "LoginEmailEntry",
"includeValues": true
}
}
App State Diagnostics
Get MAUI Resource State
Arguments:
nodeId: optional node id or AutomationIdscope:effective,application,window,page, orelement; defaulteffectiveincludeValues: include shallow value snapshots; defaultfalseincludeMergedDictionaries: include merged dictionary summaries; defaulttruemaxEntries: maximum entries per dictionary; default16
{
"toolId": "maui.get_resource_state",
"arguments": {
"nodeId": "LoginPage",
"scope": "effective",
"includeMergedDictionaries": true
}
}
Get MAUI Navigation State
Arguments:
includeWindows: include all application windows; defaulttrueincludeShellItems: include Shell item, section, and content summaries; defaulttrue
{
"toolId": "maui.get_navigation_state",
"arguments": {
"includeShellItems": true
}
}
Get Layout Diagnostics
Arguments:
nodeId: required node id or AutomationId
{
"toolId": "maui.get_layout_diagnostics",
"arguments": {
"nodeId": "SubmitButton"
}
}
Get Handler Diagnostics
Arguments:
nodeId: required node id or AutomationIdincludePlatformViewProperties: include shallow native platform-view public property snapshots; defaultfalsemaxProperties: platform-view property limit; default32
{
"toolId": "maui.get_handler_diagnostics",
"arguments": {
"nodeId": "SubmitButton",
"includePlatformViewProperties": false
}
}
Actions And Waiting
Invoke Element Action
Arguments:
nodeId: required node id or AutomationIdaction:focus,unfocus,executeCommand,invokeTap,toggle,setText, orselectPickerItemcommandName: command property name forexecuteCommand; defaultCommandparameterJson: optional command parameter encoded as JSONvalueJson: required bysetTextandselectPickerItemrequireCanExecute: fail when a command returns false fromCanExecute; defaulttrue
{
"toolId": "maui.invoke_element_action",
"arguments": {
"nodeId": "SubmitButton",
"action": "executeCommand"
}
}
Wait For MAUI UI
Arguments:
condition:elementExists,elementVisible,propertyEquals,currentPage, orbindingContextPropertyEqualstimeoutMs: default5000pollIntervalMs: default100nodeId,automationId,typeName,labelContainspropertyNameandexpectedJsonfor value conditionsrootandmaxDepthfor element searches
{
"toolId": "maui.wait_for_ui",
"arguments": {
"condition": "elementVisible",
"automationId": "SubmitButton",
"timeoutMs": 5000
}
}
Binding Context Mutation
Invoke Binding Context Command
Arguments:
nodeId: required node id or AutomationIdcommandName: publicICommandproperty name;Commandsuffix is optionalparameterJson: optional command parameter encoded as JSONrequireCanExecute: fail when the command returns false fromCanExecute; defaulttrue
{
"toolId": "maui.invoke_binding_context_command",
"arguments": {
"nodeId": "LoginPage",
"commandName": "SubmitCommand"
}
}
Set Binding Context Property
Arguments:
nodeId: required node id or AutomationIdpropertyName: writable public binding-context property namevalueJson: required new value encoded as JSON
{
"toolId": "maui.set_binding_context_property",
"arguments": {
"nodeId": "LoginPage",
"propertyName": "Email",
"valueJson": "\"person@example.com\""
}
}