• WPF中XAML转义字符


    字符

    转义字符

    备注

    & (ampersand)

    &

    这个没什么特别的,几乎所有的地方都需要使用转义字符

    > (greater-than character)

    >

    在属性(Attribute values)中必须进行转义,在内容(Content)中 如果没有<在>符号的前面,可以不进行转义,直接使用>

    < (less-than character)

    &lt;

    在属性(Attribute values)中必须进行转义,在内容(Content)中 如果没有>在<符号的后面,可以不进行转义,直接使用<

    " (straight quotation mark)

    &quot;

    在属性(Attribute Values)中必须进行转义,在内容(Content)中可以直接使用,而不进行转义。需要注意的是如果属性使用'来定义属性,那么"可以直接使用如

    Text='test"test"test',反之如果是用”来定义属性,那么'可以直接使用而不需要转义字符,如Text="test'test"

    ' (single straight quotation mark)

    &apos;

    同上

    (numeric character mappings)

    &#[integer]; or &#x[hex];

    可以和字符集合映射,如&#100;(10进制)或者&#xff;(16进制)

    回车:&#x000D;换行:&#x000A;Tab:&#x0009;空格:&#x0020;

    (nonbreaking space)

    &#160; (assuming UTF-8 encoding)

    Flow Document的元素或者有Text属性的元素,输出不间断空格

    {

    {}{

    当{}使用的时候,{可以直接使用(功能类似与string text=@"E: est.txt";中的@)

    {}的转义用法示例:
    <StackPanel Name="stacky">
      <StackPanel.Resources>
        <DataTemplate DataType="{}{http://planetsNS}Planet" >
          <StackPanel Orientation="Horizontal">
            <TextBlock Width="100" Text="{Binding Path=Element[{http://planetsNS}DiameterKM].Value}" />
            <TextBlock Width="100" Text="{Binding Path=Attribute[Name].Value}" />
            <TextBlock Text="{Binding Path=Element[{http://planetsNS}Details].Value}" /> 
          </StackPanel>
        </DataTemplate>
      </StackPanel.Resources>
    
  • 相关阅读:
    Android Studio “Project Structure”选项目录结构显示异常
    Android 不通过USB数据线调试的方法
    Android OpenGL ES 开发教程 从入门到精通
    Android NIO(Noblocking I/O非阻塞I/O)小结
    phpStudy3——往数据库中添加数据
    phpStudy2——PHP脚本访问MySql数据库
    phpStudy1——PHP文件获取html提交的参数
    php页面的基本语法
    安装使用phpStudy在本机配置php运行环境
    运行php网站需要安装什么
  • 原文地址:https://www.cnblogs.com/hyqing/p/4497494.html
Copyright © 2020-2023  润新知