WPF StringFormatは、XAMLバインディングプロパティで使用されます

1.バインディング通貨、文字なしならば、その後、なしに間違って行く= {}の後ろに加入する必要があります。

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

2.通貨結合、及び前にいくつかの文字を追加しない。上記と比較して、存在しません} {

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

3.バインディング日

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

4.バインドタイム

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

バインディング5.複数

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

6.複数のバインディングなど\トンなどの特殊文字、

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

次のように特殊文字は次のとおりです。

  • \ A&#のX07; BEL
  • \ bの&#X08; BS - バックスペース
  • \ F&#のx0c。FF - フォームフィード
  • \ nは&#のX0A。LF、NL - 改行、ニューライン
  • \ R&#のx0d; CR - キャリッジリターン
  • \ tの&#x09の。HT - タブ、水平Tabelator
  • \のV&#X0B。VT - 垂直Tabelator

ます。http://blog.jinlook.com/post/2012/07/23/XAMLBindingStringFormat.aspxからの振替

 

ます。https://my.oschina.net/garyun/blog/602721で再現

おすすめ

転載: blog.csdn.net/weixin_34409703/article/details/91774591