Nullify the value binding on IntegerUpDown from spinner

295 Views Asked by At

Is it possible to set the Minimum value of the IntegerUpDown (or any UpDownBase) to null?

The way I would like the control to operate is:

  • Initialize as null
  • Start at 0 if the user increments the spinner
  • Return to null if the user decrements from 0

I tried various combinations of setting IntegerUpDown.Minimum and IntegerUpDown.DefaultValue, but the setter on the property binding seems to re-invoke with the previous value after nullifying (can update with explanation if warranted).

1

There are 1 best solutions below

3
On

You can define nullable integer (or other variables that doesn't have the null option by default) like this:

int? IntegerUpDown = null;
if (IntegerUpDown.HasValue)
{
    int NewInt = IntegerUpDown.Value;
}