0

I'm working an Windows Universal App for our website which is a blog that runs on WordPress. The app gets data from the RSS feed of the website. The problem I'm in now is on how to display the content of each article. A sample content of an article looks like:

Lorem ipsum dolor sit amet, no has adhuc epicurei assentior, cum eu lorem viris. Dicant corpora vulputate mea at. Ad sed audiam comprehensam. Pri debitis mentitum pericula ad, conceptam instructior ex mei.<!-- more --> <img class="alignnone size-medium wp-image-2131" src="http://www.sample.com/sampleimage.jpg" alt="wideimage" width="570" height="270"/>No quem voluptua qui, viris tation facilisis ei pri. Pri an enim soluta prodesset, ea est elitr vitae admodum. Ei unum cibo libris per, sit dicit saperet gubergren in, vix ut diam deleniti. Ad mea maluisset aliquando cotidieque. Corrumpit consetetur vim ea, eos ea esse natum phaedrum. Vide falli ea duo, fierent volutpat facilisis ei est, pro ex viris primis. Vel elit mutat reformidans ex, modus postulant duo et. <a title="Hyperlink" href="http://samplewebsite.com" target="_blank">Hyperlink</a><em>Bold text</em>

As you can see the content of the aritcle contains HTML tags like img, em, a and more. Now I can display the content using a WebView, but the quirks of WebView like pinch zooming, automatic horizontal scrolling and others doesn't seem good for reading in an app.

The content is stored in a string, how do I convert HTML to XAML UI Elements and display them without using WebView.

1 Answer 1

1

WebView would be the natural fit for HTML content (or consider an HTML/JavaScript app rather than Xaml). If you want the data viewable but not manipulatable then you can use a WebViewBrush. If you want the WebView to be semi-live you can also inject javascript into your WebView to prevent scrolling (see How to disable WebView scrolling in Windows 8.1 )

There isn't a straightforward way to convert HTML to Xaml. You would need to parse the HTML and convert it manually. For simple markup this may be trivial. For complicated pages it will be difficult or impossible to automate. Libraries such as HtmlAgilityPack can help parse the HTML so you can then convert the tree into similar Xaml blocks (likely within a RichTextBlock if I understand your scenario)

1
  • The link you gave for disabling scrolling, it disables both horizontal and vertical scrolling. I want to disable only horizontal scrolling. Feb 12, 2015 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.