Rich text editing: RichTextBox or the HTML Editor

    WPF offers two practical routes to a rich text editor: the built-in RichTextBox, which edits a FlowDocument, and an HTML editor control, which stores HTML. The right choice depends on where the formatted content is used after the user saves it. This guide gives the deciding factors and the XAML and code to load and save content with the WPF HTML Editor.

    The real SpiceLogic WPF HTML Editor with a formatted sample HTML template, its complete editing toolbars, and Design, Source and Preview controls.
    The real SpiceLogic WPF HTML Editor with a formatted sample HTML template, its complete editing toolbars, and Design, Source and Preview controls.
    Choose by the saved format: FlowDocument, saved as XAML or RTF for document-format workflows; HTML for email bodies, reusable templates and web content.
    Choose by the saved format: FlowDocument, saved as XAML or RTF for document-format workflows; HTML for email bodies, reusable templates and web content.

    Decide by where the content goes

    Formatting on screen looks the same in both controls. The difference is the format you are left holding afterwards.

    What you needRichTextBoxWPF HTML Editor
    Saved formatFlowDocument, saved as XAML or RTFHTML
    Send the content as an email bodyConvert to HTML firstUse the saved HTML as it is
    Show the content on a web page or in a reportConvert to HTML firstUse the saved HTML as it is
    Bind the content to a view modelYou write the bridge to the documentBind BodyHtml as a string
    Formatting toolbar, table and image dialogsYou build themIncluded
    Mail-merge placeholders for templatesYou build themIncluded
    Source view for the markupNot applicableIncluded, with a preview

    When RichTextBox is enough

    Choose RichTextBox when the formatted text is written and read only inside your own application: internal notes, a comments field, a document that is printed from the same window. The FlowDocument never has to leave the application, and a few formatting commands cover the need.

    When to choose an HTML editor

    Choose the HTML Editor when the content leaves the window. Typical cases:

    • Users compose email messages or reusable email templates that your application sends.
    • Content is stored in a database and later shown on a website, a customer portal or a report.
    • Users paste from Word or Outlook and expect the formatting to arrive intact.
    • Templates carry placeholders such as a customer name that your code fills in at send time.

    In each case the editor already produces the format the destination expects, so there is no conversion layer to write, test and maintain.

    Load and save HTML

    Add the control from NuGet (Install-Package SpiceLogic.HtmlEditor.WPF) and bind BodyHtml to a string property on your view model:

    <editor:WpfHtmlEditor x:Name="TemplateEditor"
                          BodyHtml="{Binding TemplateBody, Mode=TwoWay}" />
    

    The same property works from code. Use DocumentHtml when you need the complete document, including the head.

    // Load the saved message into the editor
    TemplateEditor.BodyHtml = template.Body;
    
    // Save what the user wrote
    template.Body = TemplateEditor.BodyHtml;
    
    ' Load the saved message into the editor
    TemplateEditor.BodyHtml = template.Body
    
    ' Save what the user wrote
    template.Body = TemplateEditor.BodyHtml
    

    The saved string is ready to use as an email body or to store in a text column.

    Next steps

    Last updated on Nov 11, 2026

    Put this into practice.

    Clone the C# and VB.NET sample projects from GitHub. Start with Quickstart, then explore the feature samples.

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