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

[Solved] RadNumericBox - Too much precision

1 Answer 87 Views
NumericBox for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ben
Top achievements
Rank 1
Ben asked on 19 Aug 2014, 08:29 PM
I have an issue that I just can't figure out.

Using the RadNumericBox's increase or decrease button, then entering the text box change value.

I have included screenshots.

And here is the XAML.

<Input:RadNumericBox x:Name="rnDD" Grid.Row="2" Grid.Column="0" LargeChange="1" Maximum="24" SmallChange="0.1" Margin="5,5,5,5" VerticalAlignment="Center" HorizontalAlignment="Center" MinWidth="0" ValueFormat="{}{0,0:N1}"/>

1.0 becomes: 1.00000001490116

Thanks

1 Answer, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 22 Aug 2014, 07:27 AM
Hi Ben,

Thank you for contacting us.

The RadNumericBox displays the actual value of its Value property when you focus the TextBox of the control. The ValueFormat property is used to format the value when the TextBox is not focused, but it does not affect the actual value. You can use the RadNumericBox.ValueChanged event to perform some sort of value coercing; or if your control is bound to a view model, then you can perform the coercing there.

Here is a sample of how to use the ValueChanged event to round the value:
private void NumericBox_ValueChanged(object sender, EventArgs e)
{
    var nb = sender as RadNumericBox;
    if (nb.Value != null)
    {
        var value =(double)nb.Value;
        var rounded = Math.Round(value);
        if (rounded != value)
        {
            nb.Value = rounded;
        }
    }
}

I hope this helps. Please, let us know if you have further questions.

Regards,
Rosy Topchiyska
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
NumericBox for XAML
Asked by
Ben
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Share this question
or