HTML editor API reference

    The Avalonia edition exposes native framework controls and awaited document services. Use the operation suited to the currently visible content and await its actual result.

    Avalonia HTML Editor with complete native toolbars and a readable project update document.
    Avalonia HTML Editor with complete native toolbars and a readable project update document.
    MemberUse
    ContentLoad/export HTML, inspect elements and edit authored body style.
    SelectionRead/set the visible Source draft or rendered selection using UTF-16 positions.
    FormattingFormat editable Design content or use the six supported Source tag wrappers.
    StateQueryRead formatting and command availability.
    EditorUse current-view clipboard, history, deletion, scrolling, search, print and focus operations.
    CaretRead actual offsets and available geometry; navigate the visible editing surface.
    DialogOpen native authoring workflows and customize ten typed fresh-window factories.
    MailMergeInsert, discover and merge template fields.
    TableAuthoringServiceCreate/revise tables and cells.
    SearchFind/replace in rendered content or the visible source draft.

    BodyHtml and DocumentHtml support binding. The native Border uses Child for its visual layout. Content is the replaceable awaited authoring service.

    var found = await editor.Search.FindNextAsync("renewal", wholeWord: true);
    var replacements = await editor.Search.ReplaceAllAsync("renewal", "extension", wholeWord: true);
    string bodyCss = await editor.Content.GetBodyStyleAsync();
    

    Next/previous search does not wrap automatically. Replace current requires the current selected match; replace all precomputes a bounded plan and reports the actual count. Read-only and preview allow search while rejecting replacement. Source replacements stay in the visible draft and source undo history.

    Mode, editing entitlement, document identity and selection identity determine whether a mutation can apply. A null/blank SetAttributeValueOfAnElementAsync value removes that supported attribute; a missing element leaves the document unchanged.

    Hyperlink and property APIs

    SetHyperlinkAsync accepts the shared HyperLinkDialogInputs model; RemoveHyperlinkAsync removes the selected anchor while retaining its child content. HrefUrl, Bookmark, Title, InnerHtml and optional Target describe the authored hyperlink. Native file-link browsing requires an actual picker grant. ShowCtrlClickTooltipOnHyperlinks controls the shared hint when an accepted link has no title. TableAuthoringService.SetTablePropertiesAsync and SetCellPropertiesAsync apply the shared complete property models as guarded undoable changes.

    Replaceable services and notifications

    Content, Editor, Caret, Formatting, Selection, StateQuery and Dialog are non-null replaceable native interfaces. MailMerge, TableAuthoringService and Search are additional services. Mode, file and spelling events follow acknowledged work; Pasting performs synchronous bounded inspection before insertion. Passive element-click/mousedown notifications contain copied data, never executable DOM objects.

    Content also exposes XHTML/XML export, one-undo local-image embedding and unsent email construction. Native APIs are awaited adaptations; MSHTML COM objects and arbitrary Internet Explorer commands are not part of this edition.

    Related guides

    Moving from WPF

    Port the document workflow, then adapt the framework controls and awaited APIs. The Avalonia edition uses its own control and service interfaces. Keep representative documents in private tests and compare load, edit, Undo/Redo, Source, export and reopen before changing your application's production path.

    WPF integrationAvalonia integrationWhat to adapt
    WpfHtmlEditor in WPF XAMLAvaloniaHtmlEditor in Avalonia XAMLUse the Avalonia namespace, controls, brushes and application lifetime.
    BodyHtml or DocumentHtml dependency-property bindingTwo-way Avalonia binding to one matching propertyUse a view model that notifies changes. Await an export when saving current edits.
    Synchronous content and editing methodsAwaited Content, Editor, Caret, Selection, Formatting, StateQuery and Dialog operationsShow the owner, await readiness, and handle cancellation or rejection. Keep the UI thread responsive.
    Source text and mode-sensitive property accessA separate Source draft with explicit apply/discard and awaited exportExport and leaving Source apply the draft. A failed or stale apply retains it. Built-in picker Save and explicit export have distinct boundaries.
    WPF toolbar and menu controlsNative Avalonia toolbar controls, named items and context-menu APIsMove command policy and labels; recreate framework-specific presentation.
    WPF dialog factoriesTyped Avalonia dialog factoriesReturn a fresh unshown window. Let the editor manage modal ownership and selection restoration.
    Browser-relative paths and legacy browser configurationBaseUrl plus explicit file and external-resource policyA base address does not grant a file read or network fetch. Preserve authored URLs separately from safe display transport.
    WPF license entitlementStatic AvaloniaHtmlEditor.LicenseKeyUse the Avalonia entitlement before creating controls. WPF and WinForms keys do not activate this edition.
    MSHTML COM objects, IE document mode and WPF routed eventsTyped snapshots, service operations and Avalonia eventsUse copied authoring data and supported operations. These platform types do not have source or binary compatibility.

    Load and export through the current facade

    await editor.Ready;
    await editor.Content.SetDocumentHtmlAsync("<!doctype html><html><head><title>Project update</title></head><body><p>Ready for review.</p></body></html>");
    string currentHtml = await editor.Content.GetDocumentHtmlAsync();
    string currentXhtml = await editor.Content.GetDocumentHtmlAsync(true);
    string currentXml = await editor.Content.GetDocumentXmlAsync();
    

    This fragment runs after the editor attaches to a visible window. Persist the returned format through your application's save workflow. Await failures before reporting success. Do not automatically repeat a mutation after a timeout: it may already have applied.

    Replacing a service

    Implement the interface from the exact package used by your application, and route stock commands through the replacement. A Content decorator must retain this editor's table and mail-merge subservices for the stock integration. Those nested concrete services are not arbitrary independent providers. Changing a required interface member requires updating custom implementations; matching method names alone does not establish compatibility.

    Security and document checks

    Imported active content is sanitized or rejected. External resources are blocked by default. Test representative head styles, images, tables, lists and Unicode in both controls; compare semantic edited output and exact unchanged-document preservation where required. Keep document CSS separate from application Light/Dark presentation.

    See readiness and asynchronous operations, HTML input and external resources and runnable examples.

    Last updated on Oct 30, 2026

    Put this into practice.

    Start with the C# Avalonia sample. Restore this edition's package and install the native browser prerequisites before running it.

    Prefer a guided look? Book a free live demo with our engineers - live on Zoom or Teams, never a chatbot.