How to display rtf in metro app?

2019-08-04 09:01发布

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条回答
手持菜刀,她持情操
2楼-- · 2019-08-04 09:31

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.

查看更多
登录 后发表回答