How to display a text in XAML which contains double and single quotation marks?

前端 未结 3 1373
别跟我提以往
别跟我提以往 2021-02-01 00:34

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

You shoul

相关标签:
3条回答
  • 2021-02-01 01:13

    You should encode the special characters:

    <TextBlock Text='You shouldn&apos;t choose &quot;Copy if New&quot;:'/>
    
    • &apos; for '
    • &quot; for "
    0 讨论(0)
  • 2021-02-01 01:13

    There are defined XML escapes &amp; &quot; for " and &amp; &apos; for ' -- if the XML handling in XAML doesn't interpret those properly, then start to worry.

    0 讨论(0)
  • 2021-02-01 01:15

    If you don't want to encode special chars you could use:

    <TextBlock>
      <TextBlock.Text>
         You shouldn't choose "Copy if New":
      <TextBlock.Text>
    </TexBlock>
    
    0 讨论(0)
提交回复
热议问题