加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

WPF在XAML中Binding使用StringFormat属性

发布时间:2020-12-15 07:19:23 所属栏目:Java 来源:网络整理
导读:1、绑定Currency,如果没有字符的话,后面需要先加入{},不加的话会出问题 TextBlock Text= "{Binding Amount,StringFormat={}{0:C}}" / 2、绑定Currency,并在前面加入一些字符,跟上面相比,没有{} TextBlock Text= "{Binding Amount,StringFormat=Total:

1、绑定Currency,如果没有字符的话,后面需要先加入{},不加的话会出问题

<TextBlock Text="{Binding Amount,StringFormat={}{0:C}}" />

2、绑定Currency,并在前面加入一些字符,跟上面相比,没有{}

<TextBlock Text="{Binding Amount,StringFormat=Total: {0:C}}" />

3、绑定日期

<TextBlock Text="{Binding Date,StringFormat={}{0:MM/dd/yyyy}}" />

4、绑定时间

<TextBlock Text="{Binding Date,StringFormat={}{0:MM/dd/yyyy hh:mm tt}}" />

5、多重绑定

  1. ?
    <TextBlock.Text>
  2. ?
    <MultiBinding StringFormat="Delete {0} {1}">
  3. ?
    <Binding Path="FirstName" />
  4. ?
    <Binding Path="LastName" />
  5. ?
    </MultiBinding>
  6. ?
    </TextBlock.Text>

6、多重绑定中的特殊字符,如 t

  1. ?
    <TextBlock.Text>
  2. ?
    <MultiBinding StringFormat="Delete {0}&#x09;{1}">
  3. ?
    <Binding Path="FirstName" />
  4. ?
    <Binding Path="LastName" />
  5. ?
    </MultiBinding>
  6. ?
    </TextBlock.Text>


特殊字符如下:
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

?

引用自:https://blog.csdn.net/jumtre/article/details/20624753

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读