How to display rtf in metro app?

一曲冷凌霜 提交于 2019-12-24 08:58:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!