Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > NumericUpDown > NumericUpDown - ValueFormat as Pecentage

Not answered NumericUpDown - ValueFormat as Pecentage

Feed from this thread
  • Rander Castro avatar

    Posted on Jan 15, 2010 (permalink)

    Hi,

    I have trouble when trying use the NumericUpDown control with the following 
    configuration:

    ValueFormat = ValueFormat.Percentage;
    PercentiDecimalDigits = 4;

    Scenario: If I set the value 0.4  for this control, after press TAB key to exit the control, when the control lost focus, it show 4.0000 %, but I need the control shows then value that I entered, it means, 0.4000 %.

    How could I fix this, please?

    Thanks

    Reply

  • Hristo Borisov Hristo Borisov admin's avatar

    Posted on Jan 15, 2010 (permalink)

    Hi Rander Castro,

    This is expected behavior since NumericUpDown internally uses formatting with the IFormatProvider provided by the NumberFormatInfo in which formatting value of 1 is formatted as 100%. You can easily just set the ValueFormat to Numeric and set the CustomUnit to % symbol.

    Thank you for contacting us, and we look forward to answering your questions again.

    Sincerely yours,
    Hristo Borisov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Wolfgang Kaiser avatar

    Posted on May 13, 2010 (permalink)

    Hi Hristo ,

     This can't be expected behavior - definately not expected by an enduser.  I can't find the
    RadNumericUpDown control useful at all as a percentage entry utiltiy.  In order for percentage entry to work I would expect that I can 1) limit validation from 0 to 100 can be enforced - which I can't get to work and 2) if I use the numeric scroller and change my percentage from 51% to 52% and then I click on the input area to type in a percentage amount the amount will change to 0.52
     if you look at the telerik sample code the percentage input doesn't work there either - well it works but not in a useful fashion.

     I used the following to get my percentage input to work:
    <telerikInput:RadNumericUpDown x:Name="numPercent"   
    SmallChange="1" LargeChange="1"   
    Maximum="100" Minimum="0"   
    Width="100" Height="25" IsEditable="True"   
    ValueFormat="Numeric" CustomUnit="%" /> 
                     

    and then i use a value converter on the binding to convert the 40% into 0.40:
    numPercent.SetBinding(RadNumericUpDown.ValueProperty, new Binding()  
                {  
                    Converter = new PercentageConverter(),  
                    Source = txtpercentSet,  
                    Mode = BindingMode.TwoWay,  
                    Path = new PropertyPath("Text")  
                });  
     
    // and here is the value converter (test only)  
     
    private class PercentageConverter : IValueConverter  
            {  
                public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)  
                {  
                    if (value.ToString() == string.Empty) return 0;  
                    double v = System.Convert.ToDouble(value) * 100;  
                    return v;  
                }  
                public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)  
                {  
                    double v = (double)value / 100;  
                    return v;  
                }  
            } 

    Needless to say it would be nicer to have a COTS RadNumeric control that would work with percentages.

    Reply

  • Boyan Boyan admin's avatar

    Posted on May 14, 2010 (permalink)

    Hello Wolfgang Kaiser,

    I think you can achieve the desired behavior with the RadNumericUpDown  ValueFormat=Percentage. In order to limit the percentages from 0 to 100 you must set Minimum =0 and  Maximum=1. And you need to set the SmallChange to 0.01 in order for the arrows to change 1 percent down/up. I think this tweak should work fine for you. 

    All the best,
    Boyan
    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.

    Reply

  • Wolfgang Kaiser avatar

    Posted on May 14, 2010 (permalink)

    You are correct that works using the scroller, but as soon as you click inside the input field to perform manual input the value of 42% (for example) changes to 0.42.  That's not acceptable for users of our application.

    Reply

  • Valeri Hristov Valeri Hristov admin's avatar

    Posted on May 20, 2010 (permalink)

    Hi Wolfgang,

    The behavior comes from the fact that the Value of the control is displayed without formatting when the control has the focus, but when it loses the focus, the Value is formatted as percentage. String.Format("{0:P}", 1.5) will return "150%", hence the behavior of RadNumericUpDown. I admit that this is strange and we should think of a way to change it in the future, however there is another problem - if someone is used to the current behavior and all of his data is stored as the current control expects, his application will be broken.

    Regards,
    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.

    Reply

  • George Fryberger avatar

    Posted on Jun 21, 2011 (permalink)

    I agree with Wolfgang.  This is how I expected the control to work and was disappointed that it didn't.  With this information I can get it to do what I need it to but it would be nice if we could configure the control to behave like this.  Are there any plans to change this behavoir?

    Reply

  • Konstantina Konstantina admin's avatar

    Posted on Jun 24, 2011 (permalink)

    Hello Kevin,

    For now, we don't have any plans for changing the behaviour of the NumericUpDown control. However, if we receive some more clients' requests we will consider implementing it in one of our future releases.

    Please let us know if you have any other concerns about our controls.

    Kind regards,
    Konstantina
    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

    Reply

  • qwer avatar

    Posted on Jul 7, 2011 (permalink)

    I also agree with Wolfgang and Kevin,

    Our application facing same complains from end user experiences.

    From end user perspective , for 10 % they want to key in as 10 not 0.1.

    Up and Down strollers are fine and they pretty happy but when click into control, awful complains start.

    So, I strongly request Telerik team to consider/support about that feature in future release and that will be great.

    Reply

  • Yana Yana admin's avatar

    Posted on Jul 14, 2011 (permalink)

    Hello Qwer,

    Thank you for sending your feedback, it will be considered.

    Regards,
    Yana
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > NumericUpDown > NumericUpDown - ValueFormat as Pecentage
Related resources for "NumericUpDown - ValueFormat as Pecentage"

Silverlight NumericUpDown Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]