Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumericBox Decimal Places #284

Open
ManuLin opened this issue Jun 4, 2018 · 1 comment
Open

NumericBox Decimal Places #284

ManuLin opened this issue Jun 4, 2018 · 1 comment

Comments

@ManuLin
Copy link

ManuLin commented Jun 4, 2018

I'm using the RadNumericBox control for UWP with the following ValueFormat

ValueFormat="{}{0,0:#,##0.##}"

i.e. with two decimal places. The control correctly displays the current value after editing (i.e. when the control looses focus). However, the control internally seems to maintain the actual value entered, which might have more than the number of decimal places specified by the ValueFormat. Is there any possibility to limit the number of decimal places for the control regardless of the editing mode?

Any help appreciated!

P.S.: I'm using the latest version of the Telerik.UI.for.UniversalWindowsPlatform NuGet package (v1.0.1)

@APopatanasov
Copy link
Collaborator

@ManuLin If you want your value to be limited to a specific number of decimal places you can bind the Value property to a Value inside a ViewModel and inside the setter to round it as desired:
private double numericValue; public double NumericValue { get { return this.numericValue; } set { if (this.numericValue != value) { value = Math.Round(value, 2); this.numericValue = value; this.OnPropertyChanged(nameof(this.NumericValue)); } } }

and in XAML:
<input:RadNumericBox Value="{Binding NumericValue, Mode=TwoWay}" ValueFormat="{}{0,0:#,##0.##}"/>

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants