3

我在示例 itemDetailPage 中有 FlipView,并且在字符串中有文本,其中包含 html 标签(粗体、斜体)。我希望这个字符串显示在 FlipView 的richTextBlock 中,但我不知道怎么做。我正在寻找 HTML 和 XAML 之间的转换器,但没有使用 WinRT。我正在研究源代码并寻找答案,我可以将我的 html 字符串转换为 xaml 字符串。看起来像

<FlowDocument xml:space=\"preserve\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><Paragraph>Start<Run>i--</Run> something <Run>i++</Run> end of paragraph.</Paragraph><Paragraph>\n\n</Paragraph><Paragraph>Another paragraph <Run>anything</Run>. And ending.</Paragraph><Paragraph>\n\n</Paragraph></FlowDocument>

但是当我绑定到 RichTextBlock 的 Text 属性时,它只是显示为没有格式化的文本。那么如何在 RichTextBlock 中格式化文本呢?我知道可以通过添加文本块来做到这一点,但在 FlipView 中我不知道如何访问richTextBlock。我想使用 RichTextBlock,但不想为 WebView 或某些 WebControl 更改它(我喜欢 RichTextBlock 中的列排序)。

4

1 回答 1

1

是的,这个问题一直存在。Vincent H 在xslt 转换方面取得了良好的开端。我最近开始使用 Html Agility Pack扩展它。我的主要动力是处理格式非常糟糕的 Html,我认为我得到了一些至少有用的东西......

于 2012-12-31T20:26:17.587 回答