locked
String HTML in RichTextBlock

    Question

  • I need to display string html in a richtextblock (with tags: <strong>, <I>, <a href...> <br />) with bold, italic, e hyperlink

    Someone can give me a working example?

    This is a new client feature and I need to implement it quickly. I can not use the webview.

    Thank You

    p.s. for universal apps (windows 8.1 e windows phone 8.1)

    Thursday, January 15, 2015 5:11 PM

Answers

  • Why can't you use WebView? WebView is designed for HTML. RichTextBlock is not.

    Since the RichTextBlock doesn't understand HTML you'll need to parse the HTML and then translate it to Xaml block structure. For simple HTML that has a direct mapping ("<i>This is italic text</i>" to "<Italic>This is italic text</Italic>") it won't be difficult, but for more complicated HTML then it will be trickier. HTML is a much more generic markup language and can represent many more things than the RichTextBlock can.

    See the Windows.UI.Xaml.Documents namespace for the elements you can use in the RichTextBlock.

    --Rob

    Thursday, January 15, 2015 5:18 PM
    Owner