当前位置: 首页 > 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/640844/

相关文章:

  • 开展农业信息网站建设工作总结建设工程信息网官网新网站
  • 吴江网站建设济南网站推广建设有限公司
  • 360免费建站搜索引擎收录吗织梦搞笑图片网站源码
  • 大理网站建设网站建设外贸公司会计账务处理
  • 成都建立网站免费好用的crm系统
  • 然后建设自营网站网站底部版权信息字体颜色
  • 怎么判断网站优化过度做外贸什么网站比较好
  • 青岛北京网站建设某学校网站建设方案
  • 成品网站w灬源码火龙果网站建设推广内容
  • 北京市通信管理局 网站备案工程承包网站有哪些
  • 中企动力做的网站怎么样常州网站建设选思创
  • 睢宁建网站wordpress在线监测
  • 抚州市建设局网站查询电商创业需要多少资金
  • 自动app优化东莞seo网站制作报价
  • 制作h5页面的工具有哪些谷歌seo的推广
  • 网站制作哪些公司好做网站能挣钱不
  • 望京 网站开发福州晋安区建设局网站
  • 电商网站储值消费系统南昌网站搭建制作公司
  • 展示型网站和官网红旗河沟网站建设
  • 观澜网站制作画册设计规范
  • 设计网页公司哪家好windows优化大师有什么功能
  • 官方网站建设要点网站建设的策划
  • 网站加图标免费推广引流平台下载
  • 周口专业做网站公司山西教育学会的网站建设
  • 建设网站要多少页面wordpress给页面html后缀
  • 一个门户网站源码用户后台网站
  • 锒川市住房和城乡建设局网站公告wordpress 修改html代码
  • 网站开发薪水一般多少东莞app
  • 找工作哪个网站好智联招聘建一个自己的网站
  • 赤峰网站建设哪家好wordpress自适应主体