NumericUpDown should accept null as Value
See original GitHub issueIs your feature request related to a problem? Please describe. I have a form where “0” is a total valid value, but I want to make sure the user inserted this and does not use the “default” value provided by the system. In WPF I just left the field empty (‘null’) and checked if the field is not null on save
Describe the solution you’d like
make Value nullable
Describe alternatives you’ve considered Create my own control
Additional context
Fields should be empty
If you are OK with this change, I can provide a PR for this.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:11 (11 by maintainers)
Top Results From Across the Web
make nullable Numeric up down c# - Stack Overflow
The controls uses a Value property which is of type decimal. As such, then decimal is not nullable so you can't set this...
Read more >Thread: possible to keep empty value in numeric updown?
Hi, i would like to know is there possible to keep empty value in numeric updown my numeric updown should have the following...
Read more >Initialize NumericUpDown with null in UI for WPF
Hi, By default if the Value property of the control is bound to a null value the NullValue will be shown. I recorded...
Read more >Restriction in WPF NumericUpdown (UpDown)
The UpDown control accepts null values. When the Value is set to null, the UpDown control will show zero value by default. You...
Read more >NumericUpDown and NULL values
I try to set a null value to the NumericUpDown control with the following code. Dim locNullAbleDecimal As Decimal? = Nothing numericUpDown.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I just checked TextBox too. The Text property is still nullable even after the switch to nullable ref types. I’m very surprised it was stated this isn’t common. In fact every other input control i’m aware of supports this functionality.
@danwalmsley There are many scenario where apps need to know if a user has/has-not made a selection. Zero in the case of a NumericUpDown is a valid number and is not enough to indicate no user-selection. This type of functionality is common in LOB apps where form field values are being entered. In fact every single control I am aware of has some way of keeping 'null/empty values for no user-selection.
When the NumberBox spec was widely discussed with Microsoft this was also a valid scenario. However double.NaN could be used to add this functionality. With the switch to decimal in Avalonia that was overlooked and it needs to be added back somehow.
There are two standardized ways of doing this: