简体   繁体   English

在Windows Phone中将html代码转换为xaml for RichTextBox

[英]convert html code into xaml for RichTextBox in Windows Phone

how can I format this html code: 我该如何格式化这个HTML代码:

<p>For the iPhone do the following:
<ul>
<li>Go to AppStore</li>
<li>Search by M&#229lApp</li>
<li>Download</li></ul>
</p><p>
Android To do this:
<ul>
<li>Go to the Market</li>
<li>Search by M&#229lApp</li>
<li>Download</li>
</ul>
</p>

into XAML for RichTextBox in Windows Phone? 进入XAML for Windows Phone中的RichTextBox?

Update 更新

so in result it should be: 所以结果应该是:

For the iPhone do the following: 对于iPhone,请执行以下操作:

  • Go to AppStore 转到AppStore
  • Search by MålApp 搜索MålApp
  • Download 下载

Android To do this: Android要执行此操作:

  • Go to the Market 赶集
  • Search by MålApp 搜索MålApp
  • Download 下载

In your code you can Replace < li > tags with & # 8226 ; 在您的代码中,您可以使用&#8226替换<li>标签;

See http://www.fileformat.info/info/unicode/char/2022/index.htm http://www.fileformat.info/info/unicode/char/2022/index.htm

The basic approach is to verify the html as valid and then walk the content converting to the XAML equivalent. 基本方法是将html验证为有效,然后将内容转换为XAML等效项。

There are lots of examples of attempting this online 很多在线尝试这个的例子

It is far more performant to do such a conversion on a server and pull the formatted version to the phone and then display with XamlReader.Load . 在服务器上执行此类转换并将格式化版本拉到手机然后使用XamlReader.Load进行显示会更高效

Update 更新
For each element in the HTML you'll just be adding a new TextBlock to a container (probably a StackPanel ) and for the <li> items you'll just want to prefix with a symbol to represent the bullet and adjust the left margin appropriately. 对于HTML中的每个元素,您只需要向容器(可能是StackPanel )添加新的TextBlock,对于<li>项,您只需要用符号作为前缀来表示项目符号并适当调整左边距。 You'll probably benefit from defining appropriate styles and then just applying the appropriate style for the element you're converting. 您可能会从定义合适的样式中受益,然后只为您要转换的元素应用适当的样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM