当前位置: 首页 > news >正文

孝感网站开发的公司电话阿里云个人网站建设书

孝感网站开发的公司电话,阿里云个人网站建设书,一个域名可以建几个网站,安溪住房和城乡建设网站WPF文本绑定显示格式StringFormat设置 特殊格式设置日期/时间使用系统默认样式自定义格式: 绑定多个属性(多重绑定)多重绑定中的特殊字符示例: 特殊格式设置 在Textblock等文本控件中,我们经常要显示一些日期和时间&a…

WPF文本绑定显示格式StringFormat设置

  • 特殊格式设置
  • 日期/时间
    • 使用系统默认样式
    • 自定义格式:
  • 绑定多个属性(多重绑定)
    • 多重绑定中的特殊字符
    • 示例:

特殊格式设置

在Textblock等文本控件中,我们经常要显示一些日期和时间,默认显示的日期,不是我们想要的,所以需要自定义格式,还有多个数据可能需要绑定到一个文本中,都可以通过设置StringFormat来实现

日期/时间

使用系统默认样式

<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding DtNow, StringFormat={}{0:d}}" />
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding DtNow, StringFormat={}{0:D}}" />
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding DtNow, StringFormat={}{0:m}}" />
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding DtNow, StringFormat={}{0:M}}" />
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding DtNow, StringFormat={}{0:f}}" />
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding DtNow, StringFormat={}{0:F}}" />
<TextBlock Grid.Row="6" Grid.Column="1" Text="{Binding DtNow, StringFormat={}{0:g}}" />
<TextBlock Grid.Row="7" Grid.Column="1" Text="{Binding DtNow, StringFormat={}{0:G}}" />
<TextBlock Grid.Row="8" Grid.Column="1" Text="{Binding DtNow, StringFormat={}{0:t}}" />
<TextBlock Grid.Row="9" Grid.Column="1" Text="{Binding DtNow, StringFormat={}{0:T}}" />

显示效果如下:
在这里插入图片描述

自定义格式:

<TextBox Text="{Binding DtNow, StringFormat={}{0:yyyy年MM月dd日}}" />
<TextBox Text="{Binding DtNow, StringFormat={}{0:yyyy-MM-dd}}" />
<TextBox Text="{Binding DtNow, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" />

也可以简化直接写日期格式

  <TextBlock Text="{Binding DtNow,StringFormat='yyyy年MM月dd日'}"/><TextBlock Text="{Binding DtNow,StringFormat='yyyy:MM:dd HH:mm:ss'}"/>

显示效果如下
在这里插入图片描述

绑定多个属性(多重绑定)

一个文本控件绑定多个属性合并显示,使用MultiBinding,在StringFormat中设置绑定格式{0}代表第一个属性,{1}代表第二个属性,以此类推

 <TextBlock><TextBlock.Text><MultiBinding StringFormat="数据计算:{0}/{1}={2}"><Binding Path="Value1" /><Binding Path="Value2" /><Binding Path="Result" /></MultiBinding></TextBlock.Text></TextBlock>

显示效果
在这里插入图片描述

多重绑定中的特殊字符

    \a  &#x07;  BEL\b  &#x08;  BS - Backspace\f  &#x0c;  FF - Formfeed\n  &#x0a;  LF, NL - Linefeed, New Line\r  &#x0d;  CR - Carriage return\t  &#x09;  HT - Tab\v  &#x0b;  VT - Vertical Tabelator &gt;     >(右箭头)

示例:

<TextBlock><TextBlock.Text><MultiBinding StringFormat="数据计算:{0}/{1}--&gt;{2}"><Binding Path="Value1" /><Binding Path="Value2" /><Binding Path="Result" /></MultiBinding></TextBlock.Text></TextBlock><!---->

效果
在这里插入图片描述

http://www.yayakq.cn/news/739355/

相关文章:

  • 一个好网站设计设计素材模板
  • 广西智能网站建设制作免费数据统计网站
  • 手机网站知识常州人才招聘网
  • 烟台网站推广效果好搭建网站php源码
  • 甘肃省住房和城乡建设厅网站首页wordpress帮助手册
  • 郑州艾特网站建设wordpress如何进数据库
  • ui做的好看的论坛网站wordpress支持大数据处理
  • 徐州网站开发价位表白网站制作在线
  • 深圳哪里有可以做网站跳转的公司wordpress 注册用户列表
  • 有限公司企业网站建设方案请简述网络营销的特点
  • 网站建设团队名称网站开发语言怎么看
  • 双桥网站建设医学网站建设方案
  • 怎样办一个网站哈尔滨专业做网站推广
  • 二手网站建设情况教育网站制作企业
  • 对网站分析江门做公司网站
  • 网站上设置返回首页的超链接咋做的widgets wordpress怎么建
  • discuz 网站备案信息代码电子商务网站开发项目
  • 在哪查询网站做的哪些外链自己做网站开发如何找客户
  • 广东省建设厅网站6查询网站注册时间
  • zf厂手表网站创意网名女
  • 网站建设和优化的步骤水产养殖网站模板源码
  • 登录建设厅网站的是企业锁吗网站下载视频的方法
  • 做外贸网站效果图手机建站永久免费软件
  • 网站制作替我们购买域名廊坊关键词排名优化
  • 微电影网站源码留号码的广告网站不需要验证码
  • 山石网站超市app下载安卓软件
  • flash网站需要改变wordpress教育主题
  • 郑州网站空间网站备案幕布大小
  • 毕业设计网页设计论文海口seo网络公司
  • 怎么做的网站怎么放上网前端基础知识