Skip to content

NumericUpDown: HasDecimals=False & using a bound StringFormat allows to enter a decimal point #2886

@mmarkwort

Description

@mmarkwort

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions