Display formatted text in XAML

I have simple HTML (copy / paste from the print version on some page on Wikipedia), and I want to show it in my application.

Is there a way to convert it to a more native XAML view rather than just showing the entire page in a WebView ?

+4
source share
1 answer

You can use HTML Agility Pack to parse HTML and format TextBlock or RichTextBlock. You can check RichTextBlockExtensions.LinkedHtmlFragment I wrote as an example how you can add text with links to RichTextBlock, but this only supports plain text with some basic anchor tags. Anything else that would require more work, and I did not come across any open source library that would do this for you, since you will likely have to customize the style for a limited set of pages. Otherwise, writing a general HTML to XAML converter is probably an attempt similar to introducing a new web browser.

+3
source

Source: https://habr.com/ru/post/1444126/


All Articles