Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
795 views
in Technique[技术] by (71.8m points)

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

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% (multiplies by 100 and add % sign)

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

My current control is :

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
"{Binding Path=Percentage, StringFormat={}{0}%}"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...