RichTextBox for UWP | ComponentOne
Working with RichTextBox for UWP / Setting and Formatting Content / Html Content
In This Topic
    Html Content
    In This Topic

    The C1RichTextBox.Html property is used to assign and retrieve formatted text as HTML. When the Html property is set, the Html document is converted to a C1Document that, when displayed, resembles the Html content as much as possible. The original structure and styles are not kept.

    When the Html property is read, or exported, an Html document is generated from the current C1Document. There are two ways that html can be generated, with a stylesheet or with inline styles. You can use the GetHtml method, passing HtmlEncoding.Inline as the second parameter, to generate Html with inline style.

    The HTML text needs to be encoded in the XAML file, so, for example,  instead of <b> for bold, tags are encoded as <b>;.

    At Design Time

    To set the C1RichTextBox.Html property, complete the following steps:

    1. Click the C1RichTextBox control once to select it.
    2. Navigate to the Properties window, and enter text, for example <h1>Hello World<h1>", in the text box next to the C1RichTextBox.Html property.

    This will set the C1RichTextBox.Html property to the value you chose.

    In XAML

    For example, to set the C1RichTextBox.Html property add Html="Hello World!" to the <c1rtb:C1RichTextBox> tag so that it appears similar to the following:

    XAML Markup
    Copy Code
    <c1rtb:C1RichTextBox HorizontalAlignment="Left" Margin="10,10,0,0" Name="C1RichTextBox1" VerticalAlignment="Top" Height="83" Width="208" Html="&lt;h1&gt;Hello World!&lt;/h1&gt;" />
    

     

    In Code

    For example, to set the C1RichTextBox.Html property add the following code to your project:

    Visual Basic
    Copy Code
    Me.C1RichTextBox1.Html = "&lt;b&gt;Hello World!&lt;/b&gt;"
    
    C#
    Copy Code
    this.c1RichTextBox1.Html = "&lt;b&gt;Hello World!&lt;/b&gt;"