I am starting with Windows 8 and I am trying to convert HTML to a RichTextBlock
.
I have read that I could use this function : HtmlUtilities.ConvertToText
in a TextBlock
but I can't find a way to use this function in a RichTextBlock
!
From what I understand and tried I can't extend the RichTextBlock
so I can't apply this function everytime a RichTextBlock
is called.
Also, I can't find any way to bind text to a RichTextBlock
and building a parser just for simple HTML (I only want paragraphs and italics/bolds) seems an overkill. Also, I have no idea where I should do this parsing since I the RichTextBlock
seems unextendable.
I can't use the WebView
because I need transparency (and from what I have read the WebView doesn't have it).
EDIT
@mydogisbox made me see I was getting too far on my research.
I can use HtmlUtilities.ConvertToText
in the getter of a property that I can bind in the RichTextBlock
. I couldn't bind it because I was trying to do
<Run Text="{Binding TextHTML}" />
without a <Paragraph>
tag.
However HtmlUtilities.ConvertToText
doesn't preserve italics or bolds. Only paragraphs :/.
<Run Text>
. Now I have realized that I need a<Paragraph>
before so I could use it. I have binded it and tried to use a converter before I saw your comment. The converter was crashing but after I saw your comment I have changed my property's getter and now is working! However, I found out thatHtmlUtilities.ConvertToText
doesn't convert italics/bolds. I only need italics, bolds and paragraphs :/. Going to update the question. Thanks for your comment. – StrumaConvertToText
to parse those into italics etc. – PapooseConvertToText
to something the RichTextBox can display. Should just be chained method calls in the property. – Papoose