How to set WPF string format as percent wihout multiplying by 100?

后端 未结 2 492
终归单人心
终归单人心 2020-12-05 22:30

I have a textbox bound to a property in an object. I have setup the string format to be p0.

However, when I enter 12 for example it is formatted as 1200% (multiplie

相关标签:
2条回答
  • 2020-12-05 23:23
    "{Binding Path=Percentage, StringFormat={}{0}%}"
    
    0 讨论(0)
  • 2020-12-05 23:23

    Another solution is to wrap the % in single quotes, and put it inside the curley brackets:

    <TextBlock Text="{Binding Percentage, StringFormat={}{0:#0.00'%'}}"/>
    
    0 讨论(0)
提交回复
热议问题