Formatting Service

The Formatting property of the WPF HtmlEditor control returns an IFormattingService instance that applies inline character formatting (font, color, bold/italic/underline), block formatting (alignment, indent, lists), and document-level header styles. Every method below is reachable as editor.Formatting.MethodName(...).

Toggle methods (Bold, Italic, Underline, Superscript, Subscript, StrikeThrough, ApplyList) accept a FormatOptions argument with values SetOn, SetOff or Toggle (default).

WPF HTML Editor toolbar showing Bold Italic Underline buttons mapped to the IFormattingService toggle methods

Font, size, color

void ChangeFont(string fontFamilyName, string fontSize, Color foreColor) — sets font family, font size and foreground color in a single call.

void ChangeFontName(string fontFamilyName) — sets only the font family of the current selection.

void ChangeFontSize(string fontSize) — sets only the font size of the current selection.

void ChangeForeColor(Color foreColor) — sets the foreground (text) color of the current selection.

void ChangeHighlightColor(Color highlightColor) — sets the background highlight color of the current selection.

Character formatting toggles

void Bold(FormatOptions option = FormatOptions.Toggle) — toggles, sets or clears bold formatting on the selection.

void Italic(FormatOptions option = FormatOptions.Toggle) — toggles, sets or clears italic formatting on the selection.

void Underline(FormatOptions option = FormatOptions.Toggle) — toggles, sets or clears underline formatting on the selection.

void StrikeThrough(FormatOptions option = FormatOptions.Toggle) — toggles, sets or clears strike-through formatting on the selection.

void Superscript(FormatOptions option = FormatOptions.Toggle) — toggles, sets or clears superscript formatting on the selection.

void Subscript(FormatOptions option = FormatOptions.Toggle) — toggles, sets or clears subscript formatting on the selection.

Block alignment and indentation

void AlignLeft() — left-aligns the current block.

void AlignCenter() — center-aligns the current block.

void AlignRight() — right-aligns the current block.

void RemoveAlignment() — clears any explicit alignment from the current block.

void Indent() — increases the indentation of the current block.

void Outdent() — decreases the indentation of the current block.

Lists

void ApplyList(ListTypes listType, FormatOptions option = FormatOptions.Toggle) — toggles, sets or clears a list of the supplied type. ListTypes values: BulletList (unordered), NumberedList (ordered).

Headers and clearing format

void ApplyTitleHeader(int headerNumber) — promotes the current block to <h1>..<h6> based on headerNumber.

void RemoveHeaderTitle() — demotes the current header back to a normal paragraph.

void RemoveFormatFromSelection() — removes inline formatting from the current selection.

void RemoveFormatAll() — removes inline formatting from the entire document.

WPF HTML Editor showing applied heading levels and bullet ordered list formatting from IFormattingService

Example: enforce a brand font on the selection

using System.Drawing;

editor.Formatting.ChangeFont(
    fontFamilyName: "Segoe UI",
    fontSize:       "14px",
    foreColor:      Color.FromArgb(20, 60, 110));
editor.Formatting.Bold(FormatOptions.SetOn);

Example: convert a paragraph to a numbered list

// Wrap the current paragraph in <ol><li>...</li></ol>.
editor.Formatting.ApplyList(
    ListTypes.NumberedList,
    FormatOptions.SetOn);

// Indent it once.
editor.Formatting.Indent();
Last updated on May 12, 2026