如何在包含双引号和单引号的 XAML 中显示文本? [英] How to display a text in XAML which contains double and single quotation marks?

查看:23
本文介绍了如何在包含双引号和单引号的 XAML 中显示文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 XAML 文件中,我想显示包含 引号的文本:

In my XAML file I want to display this text which contains double and single quotation marks:

您不应选择如果新建则复制".

You shouldn't choose "Copy if New".

这些都不起作用:

<TextBlock Text="You shouldn't choose "Copy if New":"/>
<TextBlock Text="You shouldn't choose ""Copy if New"":"/>
<TextBlock Text="You shouldn't choose \"Copy if New\":"/>
<TextBlock Text='You shouldn't choose \"Copy if New\":'/>
<TextBlock Text='You shouldn\'t choose \"Copy if New\":'/>

我放弃了,我可以在 XAML 中执行此操作吗?

I give up, can I do this in XAML?

推荐答案

您应该对特殊字符进行编码:

You should encode the special characters:

<TextBlock Text='You shouldn&apos;t choose &quot;Copy if New&quot;:'/>

  • &apos; for '
  • &quot; for "
    • &apos; for '
    • &quot; for "
    • 这篇关于如何在包含双引号和单引号的 XAML 中显示文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆