What is the WPF XAML Data Binding equivalent of String.Format?

You can use MultiBinding + StringFormat (requires WPF 3.5 SP1):

<TextBox.Text>
    <MultiBinding StringFormat="{}{1:#0}% up, {2:#0}% down">
      <Binding Path="PercentageOne" />
      <Binding Path="PercentageTwo"/>
    </MultiBinding>
</TextBox.Text>

Regarding Run.Text – you can’t bind to it but there are some workarounds:

  • http://fortes.com/2007/03/20/bindablerun/
  • http://paulstovell.net/blog/index.php/attached-bindablerun/

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)