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

NumericUpDown decimal places replace with 0 in persian culture #3665

Closed
HamidSepehry opened this issue Oct 29, 2019 · 1 comment
Closed

NumericUpDown decimal places replace with 0 in persian culture #3665

HamidSepehry opened this issue Oct 29, 2019 · 1 comment
Assignees
Labels
Milestone

Comments

@HamidSepehry
Copy link

HamidSepehry commented Oct 29, 2019

Describe the bug
in the sample application, when I select the Persian culture and input a decimal number such as 12.751, the input number changes to 12.000 when I leave the control.
I debugged it and realize that in Persian culture, NumberDecimalSeparator property sets to '/'. and the number: 12.751 informed to 12/751. So the TryGetNumberFromText() method cannot get the full part of that as a number and returns 12 instead of 12.751

image

So I fix this issue by changing the code below in the ValidateText method inside of NumbericUpDown class:

//var number = TryGetNumberFromText(text, isHex);
var number = TryGetNumberFromText(text.Replace(this.SpecificCultureInfo.NumberFormat.NumberDecimalSeparator, "."), isHex);
number = number.Replace(".", this.SpecificCultureInfo.NumberFormat.NumberDecimalSeparator);

I just want you to commit that part of the code in the main project and release a new branch into NuGet. thank you.

@punker76 punker76 self-assigned this Oct 29, 2019
@punker76 punker76 added the Bug label Oct 29, 2019
@punker76 punker76 added this to the 2.0.0 milestone Oct 29, 2019
@punker76
Copy link
Member

@HamidSepehry this has now been fixed, and it will be released in the next version of MahApps.Metro v2.0

amkuchta pushed a commit to amkuchta/MahApps.Metro that referenced this issue Nov 19, 2019
…ersian culture

We need to use a dynamic Regex for the number input instead a static one. So we must look for the NumberFormat.NumberDecimalSeparator and NumberFormat.NumberGroupSeparator and build a new Regex if the Culture was changed.

Closes MahApps#3665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants