WPF Binding 中使用 StringFormat
时间:2014-12-12 13:01:32
收藏:0
阅读:170
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:
 {0}

Age:
 {1}

Grade:
 {2}"> 5 <Binding Path="Name"/> 6 <Binding Path="Age"/> 7 <Binding Path="Grade"/> 8 </MultiBinding> 9 </TextBlock.Text> 10 </TextBlock>
XAML 中的特殊字符
\a  BEL
\b  BS - Backspace
\f  FF - Formfeed
\n 
 LF, NL - Linefeed, New Line
\r 
 CR - Carriage return
\t 	 HT - Tab, Horizontal Tabelator
\v  VT - Vertical Tabelator
如果同时设置 Converter 和 StringFormat 属性,则会先对数据值应用转换器,然后再应用 StringFormat。
本文参考:http://www.cnblogs.com/xiwang/archive/2013/05/26/3100009.html
评论(0)