The RichTextEditor control allows users to edit text and apply different formats to different parts of that text. The following formatting options are supported:

The easiest way to provide these formatting options to your users is using the StandardRichTextEditorToolBar. This provides a user interface for applying all of the above options. Set the Editor property to attach a toolbar to an editor:

CopyExample Usage
<ms:StandardRichTextEditorToolBar Editor="{Binding ElementName=TextEditor}" />
<ms:RichTextEditor x:Name="TextEditor" />

If you want to provide your own user interface for applying formatting, use the various Apply methods on the RichTextEditor control.

Importing and Exporting HTML

To export HTML from the RichTextEditor control, use the Html property. HTML is generated on demand and the Html property is therefore not suitable for use as a binding source (the control does not raise change notifications for it). This reflects the usual pattern of HTML editing where the user chooses when to post or preview their content, for example by clicking a button.

To load HTML into the RichTextEditor control, call the LoadHtml method. LoadHtml does not implement a full HTML parser, and will ignore elements or styles that it does not recognise. You should generally use LoadHtml only to reload HTML that was originally exported from the RichTextEditor via the Html property.

CopySetting HTML Page Content - HTML
<div id="htmlDisplay" />
CopySetting HTML Page Content - C#
private void ShowHtmlOnPage()
  HtmlElement element = HtmlPage.Document.GetElementById("htmlDisplay");
  if (element != null)
    element.SetProperty("innerHTML", TextEditor.Html);