问题
How can I show rtf strings in a RichTextBlock (or any other UI text element)? There's no rtf property I could use (different from .net I think). And if I bind the string to the normal text property I only get the rtf code itself.
So is there a way to do this? Otherwise I'd display the string as HTML in a WebView element. But I'd prefer a RichTextBlock.
回答1:
Use a RichEditBox
instead of RichTextBlock
. You can inject RTF with RichEditBox.Document.SetText() method. RichTextBlock
isn't an RTF control and doesn't understand RTF. The RichEditBox
is the only in-box control which supports RTF. If you don't want to use that then you would need to parse the RTF yourself and create the block elements for the RichTextBlock
.
来源:https://stackoverflow.com/questions/15765004/how-to-display-rtf-in-metro-app