MBZ
MBZ

Reputation: 27632

Display a formatted text in XAML

I have a simple HTML (copy/paste from printable version of some Wikipedia page) and I wanna show it in my app.

Is there any way to convert it to a more native XAML look rather than just showing the whole page in a WebView?

Upvotes: 4

Views: 1310

Answers (1)

Filip Skakun
Filip Skakun

Reputation: 31724

You could use the HTML Agility Pack to parse the HTML and format a TextBlock or RichTextBlock. You can check out the RichTextBlockExtensions.LinkedHtmlFragment I wrote for a sample of how you might go about adding some text with links to a RichTextBlock, but this only supports plain text with some basic anchor tags. Anything more would require more work and I haven't come across any open source library that would do it for you, since you would likely need to have custom styling for a limited set of pages. Otherwise - writing a generic HTML to XAML converter is probably an effort similar to implementing a new web browser.

Upvotes: 3

Related Questions