wpf StringFormat

来源:互联网 发布:陈程编程 编辑:程序博客网 时间:2024/05/22 05:01
1.<TextBlock Text="{Binding Message, StringFormat={}{0}元}"/>
2.<TextBlock Text="{Binding Message, StringFormat='yyyy-MM-dd'}"/>
3.<TextBlock Text="{Binding Message, StringFormat='yyyy:MM:dd'}"/>
<pre name="code" class="html">4.<TextBlock Text="{Binding Message, StringFormat='{}{0:D2}'}"/>   //1 -》 01
5.多重绑定
<ListBox ItemsSource="{StaticResource MyData}">  <ListBox.ItemTemplate>    <DataTemplate>      <TextBlock>        <TextBlock.Text>          <MultiBinding  StringFormat="{}{0} -- Now only {1:C}!">            <Binding Path="Description"/>            <Binding Path="Price"/>          </MultiBinding>        </TextBlock.Text>      </TextBlock>    </DataTemplate>  </ListBox.ItemTemplate></ListBox>



0 0
原创粉丝点击