码迷,mamicode.com
首页 > Windows程序 > 详细

WPF Binding 中使用 StringFormat

时间:2014-12-12 13:01:32      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   ar   color   使用   sp   for   on   

TextBlock 中 Text 格式化

TextBlock 的 Text 可以绑定多个数据源,配合 StringFormat 就可以很方便地显示了。

 1 <TextBlock Text="{Binding Text,StringFormat=Name:{0}}"/>
 2 <TextBlock FontSize="30" TextWrapping="Wrap">
 3     <TextBlock.Text>
 4         <MultiBinding StringFormat="Name:&#x0a;   {0}&#x0a;&#x0a;Age:&#x0a;   {1}&#x0a;&#x0a;Grade:&#x0a;   {2}">
 5             <Binding Path="Name"/>
 6             <Binding Path="Age"/>
 7             <Binding Path="Grade"/>
 8         </MultiBinding>
 9     </TextBlock.Text>
10 </TextBlock>

XAML 中的特殊字符

\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, Horizontal Tabelator
\v  &#x0b;    VT - Vertical Tabelator

 

如果同时设置 Converter 和 StringFormat 属性,则会先对数据值应用转换器,然后再应用 StringFormat。

 

本文参考:http://www.cnblogs.com/xiwang/archive/2013/05/26/3100009.html

 

WPF Binding 中使用 StringFormat

标签:style   blog   http   ar   color   使用   sp   for   on   

原文地址:http://www.cnblogs.com/pengzhong/p/WPFBindingStringFormat.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!