4

I have this label inside ProgressBar that take it's value form the Progressbar value and i want to add the char % after the ProgressBar value.

I have tried two options that not working:

<Label Content="{Binding Progress}" ContentStringFormat="{}{0} %" />
<Label Content="{Binding Progress, StringFormat={}{0}%}" />
Noam M
  • 3,156
  • 5
  • 26
  • 41
Verint Verint
  • 557
  • 1
  • 7
  • 19
  • possible duplicate of [Use StringFormat to add a string to a WPF XAML binding](http://stackoverflow.com/questions/19278515/use-stringformat-to-add-a-string-to-a-wpf-xaml-binding) – Dour High Arch May 31 '15 at 20:08

2 Answers2

4

e.g. with ContentStringFormat:

<Label Content="{Binding Progress}" ContentStringFormat="{}{0} %" />

or you use Standard Numeric Format Specifier P

ContentStringFormat="{}{0:P}"

This all is very similar to String.Format.

LPL
  • 16,827
  • 6
  • 51
  • 95
  • On my case, I needed concatenate a Binding variable with a static String. Worked perfectly with this code! – Lücks Mar 31 '16 at 14:57
3

Use a TextBlock instead.

<ProgressBar Value="50" Name="prog" ... />

<TextBlock Text="{Binding Path=Value, ElementName=prog, StringFormat={}{0}%}"/>
Mike Eason
  • 9,525
  • 2
  • 38
  • 63