This is a migrated thread and some comments may be shown as answers.

Multiplying by 100 when percentage format is set

1 Answer 265 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Elifbars
Top achievements
Rank 1
Elifbars asked on 30 Jul 2010, 09:39 AM
Hello,
I have numericUpDown in my project which valueFormat should be percentage
Here is my xaml code:

<telerik:RadNumericUpDown Grid.Row="1" Grid.Column="1" Name="VMDCR"
                                Value="{Binding Path=Tier.VMDCR,ValidatesOnDataErrors=True,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
                                IsEditable="True" AutoReverse="False" Minimum="0"
                   SmallChange="0.1" LargeChange="0.1" ValueFormat="Percentage" >

So when window with numericUpDown appears it's value is 0.00%
When i select all it's content and type here it's value becomes for example 34 , but after it loses focus the value is set to 3,400.00% but i expect that it would be 34.00%.
So, please, could you explain how can i achieve this? Why does the value multiply by 100 and how to avoid this behaviour?

1 Answer, 1 is accepted

Sort by
0
Accepted
Valeri Hristov
Telerik team
answered on 02 Aug 2010, 11:13 AM
Hello Elifbars,

RadNumericUpDown uses String.Format() to format its string depending on the current culture and number format. The behavior of String.Format() is to multiply the value by 100 when it formats using percentage number format. For example the result of:

String.Format("{0:P}", 5d);

will be "500.00 %" (the decimal separator depends on your culture settings).

To workaround this behavior you could use ValueFormat="Numeric" and set CustomUnit="%" - this way the control will behave as with regular numbers, but will display "%" at the end.

Sincerely yours,
Valeri Hristov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
NumericUpDown
Asked by
Elifbars
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or