wpf - StringFormat with value zero -


i'm developing wpf application componentart have textblock this

<textblock fontsize="28" text="{binding datapoint.y, stringformat=\{0:#\\%\}}" foreground="black"> 

as can see, stringformat puts '%' sign after number, if data 0.0 (i fill component in code behind, variable double) "%", want "0%", how can this?

you can use different stringformat. instead of 0:# put 0:0:

<textblock fontsize="28" text="{binding path=mydouble, stringformat=\{0:0\\%\}}" foreground="black"/> 

quoting msdn:

#: replaces "#" symbol corresponding digit if 1 present; otherwise, no digit appears in result string.

0: replaces 0 corresponding digit if 1 present; otherwise, 0 appears in result string.


Comments