Viraj Shah
Viraj Shah

Reputation: 308

How to convert HTML codes to XAML in Windows Phone

I am creating Windows Phone Application, I am getting HTML codes from web service response, like

"&nbsp;,<br>"

how do I convert them in xaml? is there any static method available?

because I have tried HttpUtility mehtod but not getting the converted result

Upvotes: 2

Views: 2252

Answers (2)

mYnDstrEAm
mYnDstrEAm

Reputation: 789

Maybe you could use this HTML to XAML FlowDocument converter: http://blogs.msdn.com/b/wpfsdk/archive/2006/05/25/606317.aspx

Then you could use a custom control, here's an example:

<ControlTemplate TargetType="{x:Type local:ReplyBoxControl}">
   <Border BorderBrush="Black" BorderThickness="1" Background="#F0E0D6" MaxHeight="320" Width="300">
         <FlowDocumentScrollViewer VerticalScrollBarVisibility="Auto" MaxHeight="320" Height="Auto"
Document="{TemplateBinding TestText2, Converter={StaticResource HtmlToFlowDocumentConverter}}" />
   </Border>
</ControlTemplate>

Upvotes: 1

Claus J&#248;rgensen
Claus J&#248;rgensen

Reputation: 26347

There is no built-in functionality to do this. You'll need to manually map the content to a <RichTextBox /> and insert the necessary <Paragraph /> and <Run /> elements as necessary.

Upvotes: 3

Related Questions