Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

New control for properly displaying HTML content #268

Closed

Description

I think a solid control for displaying content doesn't exist at the moment. Sure, you can use a WebView control, build yourself a HTML template, add some CSS and all the things. But this makes it still complicated to use the WebView in a FlipViewItem for e.g. next/previous behaviors.

The HtmlBlock control from the Windows App Studio Libraries renders HTML into XAML. In my opinion this is a damn bad approach, as HTML can be really shitty and it could break the parser. Maybe there's another solution to fix the WebView problems.

Activity

  1. deltakosh commented on Aug 30, 2016

    @deltakosh
    Contributor

    I'm not sure to get why using the Webview is complicated. Can you picture it a little bit more?

  2. ScottIsAFool commented on Aug 30, 2016

    @ScottIsAFool
    Contributor

    @deltakosh the webview might not be difficult as such, but it adds a significant memory overhead that would be preferred to be avoided.

  3. deltakosh commented on Aug 30, 2016

    @deltakosh
    Contributor

    But how do you want to render HTML without a webbrowser? :)

  4. Hanzalah-Adalan commented on Aug 31, 2016

    @Hanzalah-Adalan

    @jlnostr I have an unanswered issue for the HtmlBlock control.. I think the control has been deprecated since it's not brought into this new UWP Community Toolkit.. There must be a real reason why they ignore it..
    wasteam/waslibs#45

  5. javitosanchez commented on Aug 31, 2016

    @javitosanchez

    In my experience the webview approach has 2 problems/limitations:

    • Memory consumption
    • The webview control handles it's own scroll, so it's not posible to include it into a scrollview. This limits any kind of layout composition

    It's obvious that the best way to render html is using the webview control, but currently most of the content providers (rss, YouTube, Twitter...) uses the html as format. In order to apply a look & feel to your html content you will need to inject some amount of css, and this increase the complexity because you are mixing html/css and xaml. Here is were the HtmlBlock control makes sense.

  6. deltakosh commented on Aug 31, 2016

    @deltakosh
    Contributor

    @jlnostr and this control should be interactive I guess?

  7. ScottIsAFool commented on Aug 31, 2016

    @ScottIsAFool
    Contributor

    @deltakosh if by that you mean things like clicking on hyperlinks, yes :)

  8. deltakosh commented on Aug 31, 2016

    @deltakosh
    Contributor

    So you need a browser which in turn needs memory. I do not see what we can do better here.

    For webview integration in other control, I'm afraid this is beyond toolkit responsability and this is more an ask for XAML team. (you can use their uservoice for this: https://wpdev.uservoice.com/forums/110705-universal-windows-platform)

  9. hermitdave commented on Sep 1, 2016

    @hermitdave
    Contributor

    Folks,

    I have needed this in past and i started with this control
    https://github.com/MyToolkit/MyToolkit/tree/master/src/MyToolkit.Extended/Controls/Html

    However I couldn't style it and due to lack of time I eventually moved to using HTML to XAML transform

    It would be great to implement at least a limited HTML to RichTextBlock transform

  10. Odonno commented on Sep 2, 2016

    @Odonno
    Contributor

    @hermitdave Same, have used a HTML2XAML component but not really enjoy by it because it is very limited. Is there any solution to create an Embedded HTML view inside a XAML component ?

    I mean, my current use case is to create a ListView where each item has a DataTemplate that contains some XAML stuff and an HTML block view.

  11. deltakosh commented on Sep 2, 2016

    @deltakosh
    Contributor

    I do not see how you can handle all the complexity of CSS + html + JS on a custom control without relying on an effective browsers.
    This control has to be perfect or you will spend ages dealing with support and maintenance.

  12. ScottIsAFool commented on Sep 2, 2016

    @ScottIsAFool
    Contributor

    @deltakosh I would say most use cases don't require parsing complex html/css/javascript

  13. deltakosh commented on Sep 2, 2016

    @deltakosh
    Contributor

    "most"
    The risk could be reduced with a SOLID documentation perhaps

  14. deltakosh commented on Sep 2, 2016

    @deltakosh
    Contributor

    But once again, I do not want to block this control. Let's try and see how it could work

  15. hermitdave commented on Sep 3, 2016

    @hermitdave
    Contributor

    My thoughts.

    1. No JS support. This is an HtmlView control. it renders Html and that's about it.
    2. We start with basic html tags. I'd suggest a subset of HTML4
    3. CSS again would be a no no.. we could look at inline style attribute as that isn't that bad an option.
  16. Dinchy87 commented on Sep 6, 2016

    @Dinchy87

    I also tried to make my own solution instead of the webview, parsing all the elements of a html document in a richtextblock or different xaml elements inside a scrollviewer but in the end it gets to the same as the webview. Handling JS and cookies and caching and so on there is the webview better and i thought if i do it further i will get to the point of a basic webview. So for me its the same. Maybe the webview is an memory hog, yes, but it also has a lot of options to display html. My own solution maybe has reduced the memory footprint but still lacks of polish, functions and usabilty. It was too narrowed down to my own case of a RSS source parsing to html.

    Years ago this is why i found HtmlAgilityPack for parsing webpages and then switched (just display html instead of parsing/scraping) to a WebControl and now WebView. It gets better and better.

  17. deltakosh commented on Sep 6, 2016

    @deltakosh
    Contributor

    @hermitdave I still don't buy it as this is too restrictive to be used. I would prefer a MDView then. At least we can support everything for this one

  18. hermitdave commented on Sep 6, 2016

    @hermitdave
    Contributor

    @deltakosh i agree.. markdown would be easier to support than html

  19. Odonno commented on Sep 6, 2016

    @Odonno
    Contributor

    Sounds good to me.

  20. deltakosh commented on Sep 6, 2016

    @deltakosh
    Contributor

    Ok closing this one and opening a new one for MDView (#300)

  21. Odonno commented on Sep 20, 2016

    @Odonno
    Contributor

    Had an idea today. I don't know if it's feasible but why not a RuntimeDataTemplate, with a possible RuntimeDataTemplateSelector ?

    I mean, imagining I have a ListView and each element inside of the list is pure HTML. I can't bind to a simple DataTemplate since the template is variable (based on the content of the HTML). So, a solution could be an HTML to DataTemplate renderer that will be created dynamically inside the DataTemplateSelector.

    What do you think ?

    EDIT : Of course, JavaScipt is banned and CSS is not really considered.

  22. hermitdave commented on Sep 20, 2016

    @hermitdave
    Contributor

    You'd still need templates to render specific html types. How would your handle nesting of html tags. It's a can of worms IMO unless you can define a strict behaviour

  23. Odonno commented on Sep 20, 2016

    @Odonno
    Contributor

    In my opinion, I think it should be flexible. I mean, a <div> should be a Grid, or maybe the content that contains class="row" should be a Grid. That's entirely up to you to define the behaviour.

    Maybe there could be a default behaviour and then you can extend or rewrite the entire generation.

  24. deltakosh commented on Sep 20, 2016

    @deltakosh
    Contributor

    I'm still convinced we should not try to parse HTML but instead concentrate on MD parsing

  25. Odonno commented on Sep 20, 2016

    @Odonno
    Contributor

    Or maybe both. :)

    You're right, we should try first with MD, and if it works, then try HTML.

  26. andrewleader commented on Sep 20, 2016

    @andrewleader
    Contributor

    +1 for both, I've needed something for HTML before (when I wrote a Craigslist app), and I ended up writing my own HTML -> RichTextBlock. There's definitely sometimes a need for lightweight simple HTML -> native controls translation.

  27. ghost locked as resolved and limited conversation to collaborators on Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions