我有一个文本框绑定到对象中的属性.我已将字符串格式设置为p0.
但是,当我输入12时,例如它被格式化为1200%(乘以100并添加%符号)
如何设置stringformat以便例如20格式化为20%?
我目前的控制是:
<TextBox Text="{Binding Path=MyCase, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, StringFormat=p0}"/>
Run Code Online (Sandbox Code Playgroud)
如何改变字符串格式,使7的格式为7%而不是700%?
Tho*_*que 85
"{Binding Path=Percentage, StringFormat={}{0}%}"
Run Code Online (Sandbox Code Playgroud)
另一个解决方案是将 括%
在单引号中,并将其放在大括号内:
<TextBlock Text="{Binding Percentage, StringFormat={}{0:#0.00'%'}}"/>
Run Code Online (Sandbox Code Playgroud)