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: HasDecimals=False & using a bound StringFormat allows to enter a decimal point #2886

davericardo opened this Issue Mar 9, 2017 · 0 comments


None yet
2 participants

davericardo commented Mar 9, 2017

I want to show a unit e.g. 's' in the NumericUpDown:

<mahControls:NumericUpDown Value="{Binding Value, Mode=TwoWay}" StringFormat="{Binding ValueUnit}" HasDecimals="False" />

In this case I am allowed to enter a decimal point. But if I don't use a binding for StringFormat property

<mahControls:NumericUpDown Value="{Binding Value, Mode=TwoWay}" StringFormat="{}{0} s" HasDecimals="False" />

it works as expected. The entering of a decimal point is prohibited.

After reading some code I think I found the line that leads to the described case:
nud.HasDecimals = !RegexStringFormatHexadecimal.IsMatch((string)e.NewValue); in NumericUpDown.cs, OnStringFormatChanged

That could explain why the HasDecimals property is only changed if I use a Binding.

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