如何将 WPF 字符串格式设置为不乘以 100 的百分比? [英] How to set WPF string format as percent wihout multiplying by 100?

查看:21
本文介绍了如何将 WPF 字符串格式设置为不乘以 100 的百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定到对象属性的文本框.我已将字符串格式设置为 p0.

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

但是,例如,当我输入 12 时,它的格式为 1200%(乘以 100 并添加 % 符号)

However, when I enter 12 for example it is formatted as 1200% (multiplies by 100 and add % sign)

如何设置字符串格式,例如将 20 格式化为 20% ?

How can i set the stringformat so that for exampe 20 is formatted as 20% ?

我目前的控制是:

<TextBox Text="{Binding Path=MyCase, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, StringFormat=p0}"/>

如何更改字符串格式,使 7 的格式为 7% 而不是 700%?

how t change the string format so that the format for 7 is 7% not 700% ?

推荐答案

"{Binding Path=Percentage, StringFormat={}{0}%}"

这篇关于如何将 WPF 字符串格式设置为不乘以 100 的百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆