【问题标题】:Formatting text in RichTextBlock in FlipView在 FlipView 的 RichTextBlock 中格式化文本
【发布时间】:2013-01-01 04:26:17
【问题描述】:

我在示例 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 中的列排序)。

【问题讨论】:

    标签: c# html xaml windows-runtime


    【解决方案1】:

    是的,这个问题一直存在。 Vincent H 以an xslt conversion 开了个好头。我最近开始使用 Html Agility Pack 和 expanded it。我的主要动力是处理格式非常糟糕的 Html,我认为我得到了一些至少有用的东西......

    【讨论】:

    • 谢谢。我会看看它并尝试它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-28
    • 1970-01-01
    • 2012-10-01
    • 2014-01-13
    • 2019-09-10
    • 1970-01-01
    相关资源
    最近更新 更多