Store and display rich text

I need to store a significant amount of rich text in an SQL database, extract and display it.

One font is fine, but I need different font sizes / bold / color.

Now I use RichTextBox (WPF) to display it and XamlWriter.Save/XamlReader.Parse to serialize it to rows for storage in the database. It works well, but the RichTextBox is so HUGELY SLOW when displaying text that it is basically unsuitable.

Is there a quick way to do this with acceptable performance?

I am considering doing this with GlyphRun objects, drawing each character as a bitmap and calculating all alignment requirements to fit the target image, etc. But reinventing the wheel in plain color / meaningful text seems weird in 2011.

EDIT : Thanks for the answers, have not seen them so far, sorry.

The text is entered by the user from RichTextBoxes, basically I just save the result string XamlWriter.Save(richTextBox.Document)in the database. Other fields (double / int, etc.) are also entered by the user from TextBoxes.

When a user requests a database, read-only extended text pages with colors and formatting are generated from scratch using the fields in the database, including the saved text fields above: they are converted from FlowDocumentto Spanand some replacement is done on them ( InlineUIContainerin which the class is placed, obtained from UIElement, which refers to a database record embedded in the text, for example "see [thisbook]", where [thisbook] refers to the identifier of the database record). MSDN says there is TextBlocktoo much text for the text.

, , , , WPF RichTextBox es: RichTextBox es, , ...

RichTextBox es, ( Paragraph/Section/Span), / .

, , (AvalonEdit FormattedText GlyphRun) , , API XamlWriter.Save XamlReader.Parse ( FormattedText GlyphRun, , ).

OpenXML SDK Microsoft Word.docx, Google , , , UIElement InlineUIContainer , , ( AvalonEdit).

+5
1

RichTextBox, HUGELY SLOW (). AvalonEdit. RichTextBox .

, , TextBlock - :

<TextBlock>
   <Run FontWeight="Bold">Hello</Run>
   <Run Foreground="Green">World</Run>
   <Run FontSize="24">!</Run>
</TextBlock>
+1

All Articles