Skip to content

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

This is a UWP class library to inject HTML into a RichTextBlock easily

Usage:

  1. In a XAML file, declare the namespace:
xmlns:html="using:XAMLHtml" 
  1. In RichTextBlock controls, set or databind the Html property:
<RichTextBlock html:Properties.Html="{Binding ...}"/>

or

<RichTextBlock>
<html:Properties.Html>
<![CDATA[ <p>This is a list:</p> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul>]]>
</html:Properties.Html>
</RichTextBlock>

h1, h2 and h3 tag can apply a custom format with the following code:

HtmlProperties.H2SpanFactory=()=>newSpan{FontSize=13.71,FontWeight=FontWeights.Light};

To set a max width/height of <img> tags:

HtmlProperties.ImageMaxPixelWidth=500;HtmlProperties.ImageMaxPixelHeight=500;

All credits to https://blogs.msdn.microsoft.com/tess/2013/05/13/displaying-html-content-in-a-richtextblock/

About

Utililty to inject HTML into a XAML RichTextBlock

Resources

Stars

13 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages