Working with RichTextBox for WPF and Silverlight > Saving and Loading HTML |
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:
HTML |
Copy Code
|
---|---|
<html> <head> <style type="text/css"> .c0 { font-family:Portable User Interface;font-size:9pt; } .c1 { margin-bottom:7.5pt; } </style> </head> <body class="c0"> <p class="c1">Hello world.</p> </body> </html> |
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.