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

查看:169
本文介绍了如何将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%? p>

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天全站免登陆