ComponentOne RichTextBox for WPF
Working with WPF RichTextBox / Saving and Loading HTML
In This Topic
    Saving and Loading HTML
    In This Topic

    You can persist the contents of a simple TextBox control using the Text property. You can also use the C1RichTextBox.Text property to persist content in the C1RichTextBox control, but you will lose any rich formatting. Instead, you can use the C1RichTextBox.Html property to persist the content of a C1RichTextBox while preserving the formatting.

    The Html property gets or sets the formatted content of a C1RichTextBox as an HTML string. The HTML filter built into the C1RichTextBox is fairly rich. It supports CSS styles, images, hyperlinks, lists, and so on. But the filter does not support all HTML; it is limited to features supported by the C1RichTextBox control itself. For example, the current version of C1RichTextBox does not support tables. Still, you can use the Html property to display simple HTML documents.

    If you type "Hello world." into a C1RichTextBox, the Html property will return the following markup:

    Copy Code
      <style type="text/css">
        .c0 { font-family:Portable User Interface;font-size:9pt; }
        .c1 { margin-bottom:7.5pt; }
    <body class="c0">
    <p class="c1">Hello world.</p>

    Note that the Html property is just a filter between HTML and the internal C1Document class. Any information in the HTML stream that is not supported by the C1RichTextBox (for example, comments and meta information) is discarded, and will not be preserved when you save the HTML document later.