IntegerUpDown

The IntegerUpDown control provides a TextBox with button spinners that allow incrementing and decrementing Nullable<int> values by using the spinner buttons, keyboard up/down arrows, or mouse wheel.

Usage

integerupdown.jpg

When using the IntegerUpDown in data binding scenarios, bind your object's value to the Value property. You can specify how much to increment the value by setting the Increment property. You can control the minimum and maximum allowed values by setting the Minimum and the Maximum properties. Use IsReadOnly to determine whether the control is read only. If you would like to get the actual formatted string representation of the value, you can use the Text property.

Applying FormatStrings

Default:
integerupdown_default.jpg
     <xctk:IntegerUpDown Value="1564" />


Number:
integerupdown_number.jpg
     <xctk:IntegerUpDown FormatString="N0" Value="1564" Increment="1" Maximum="200000"/>


Currency:
integerupdown_currency.jpg
     <xctk:IntegerUpDown FormatString="C0" Value="1564" Increment="1" Maximum="5000" Minimum="50"/>



Supported Format Strings

Format Specifier Name
C Currency
F Fixed Point
G General
N Number
P Percent


Watermark

You can provide a Watermark to show text in place of a NULL Value.

integerupdown_watermark.jpg
     <xctk:IntegerUpDown Watermark="Enter Integer" />

Properties

Property Description
AllowSpin Gets or sets the ability to perform increment/decrement operations via the keyboard, button spinners, or mouse wheel. (Inherited from UpDownBase)
AutoMoveFocus Gets or sets if the focus can move from this control to other controls. (Inherited from NumericUpDown)
AutoSelectBehavior Gets or sets a value indicating how the content of the auto-select text box is selected (Never or OnFocus). By default, OnFocus. (Inherited from NumericUpDown)
ClipValueToMinMax Gets or sets if the value should be clipped when minimum/maximum is reached. (Inherited from UpDownBase)
CultureInfo Gets or sets the current CultureInfo. (Inherited from InputBase)
DefaultValue Gets or sets the value to use when the Value is null and an increment/decrement operation is performed. (Inherited from UpDownBase)
DisplayDefaultValueOnEmptyText Gets or sets if the defaultValue should be displayed when the Text is empty. (Inherited from UpDownBase)
FormatString Gets or sets the dispaly format of the Value.
Increment Gets or sets the amount in which to increment the value. (Inherited from NumericUpDown)
IsReadOnly Gets or sets if the control is read only. (Inherited from InputBase)
Maximum Gets or sets the maximum allowed value. (Inherited from UpDownBase)
Minimum Gets or sets the minimum allowed value. (Inherited from UpDownBase)
MouseWheelActiveTrigger Gets or sets when the MouseWheel is active (Focused, FocusedMouseOver, MouseOver, Disabled). By default, FocusedMouseOver. (Inherited from UpDownBase).
ParsingNumberStyle Gets or sets the parsing style (AllowLeadingWhite, Float, AllowHexSpecifier, ...). By default, Any. (Inherited from CommonNumericUpDown)
ShowButtonSpinner Gets or sets if the ButtonSpinners are visibles. (Inherited from UpDownBase)
Text Gets or sets the formated string representation of the value. (Inherited from InputBase)
TextAlignment Gets or sets the alignment of the Text (Left, Right, Center, Justify). By default, Left. (Inherited from InputBase)
Value Gets or sets the numeric value. (Inherited from UpDownBase)
Watermark Gets or sets the object to use as a watermark if the Value is null. (Inherited from InputBase)
WatermarkTemplate Gets or sets the DatTemplate to use for the Watermark. (Inherited from InputBase)

Events

Event Description
InputValidationError Occurs when the Text cannot be converted to a valid Value. (Inherited from UpDownBase)
ValueChanged Raised when the Value changes. (Inherited from UpDownBase)


Support this project, check out the Plus Edition.
---

Last edited Jun 17 at 5:37 PM by dlafontaine, version 12

Comments

BoucherS Jul 8, 2013 at 2:05 PM 
new Discussion tab is here : https://wpftoolkit.codeplex.com/discussions/449298

BoucherS Jul 8, 2013 at 2:04 PM 
Please use the Discussion Tab. Discussion has been created.

juliangold Jul 8, 2013 at 12:05 PM 
Having an issue with binding to Value. I have a second control with {Binding Value} on the spinner. If I click the "up" button, the spinner's value changes but this is not propagated. It will only be propagated if I click "down" or in the text edit part of the spinner.

emartin Feb 11, 2013 at 2:51 PM 
Please use DISCUSSION or ISSUE Tabs to post your usage related issues
Use theses comments only if you refer to documentation specific needs related to this page content.

emartin Feb 11, 2013 at 2:48 PM 
MRothaus, This issue has been created based on your need: http://wpftoolkit.codeplex.com/workitem/19335

MRothaus Feb 9, 2013 at 5:55 PM 
Very nice update. One minor issue I am having is if a I clear out the spinner, then leave the spinner, it is still showing an empty display. I know it is setting it internally to the DefaultValue, because if I click on an up/down spinner button, it increments from the DefaultValue. Am I missing something? I think it should show the DefaultValue on LostFocus if the text is empty.

BoucherS Feb 5, 2013 at 1:04 PM 
This will be fixed in v2.0.

Epsil0neR Feb 5, 2013 at 10:23 AM 
I set property Maximum = 2000, if i have entered any number greater than 2000, it's sets back to number which has been set before, but not maximum number as I want, maybe I didn't set some property to keep maximum if input value is greater than maximum. I think that the same problem is with property minimum.

BoucherS Jan 28, 2013 at 1:22 PM 
Using "IsReadOnly = True" will prevent user from entering data while "IsEnabled=False" will also prevent user from entering data and will gray out the data.

internetzer Jan 28, 2013 at 12:47 PM 
I can´t find IsEditable and IsReadOnly does not what IsEditable should do. So, is there a way to prevent user input in the text box?

raebot Nov 14, 2012 at 8:01 PM 
Typing with the keyboard does not seem to work. If another property updates then the keyboard-edited property suddenly commits, but otherwise it doesn't notice the keyboard input (seems to be a similar issue to andyste1 and stricq).

gishu_pillai Oct 26, 2012 at 10:23 AM 
Nicely done. No surprises from this control.. Only quirk was the control accepts blank when bound to an Integer (not nullable) - with some code to see the error in the tooltip, we get the ['' cannot be converted]. I would have liked the control to revert to the min value instead... Oh well, I ended up smoothing this out with some view code. Handle the ValueChanged event and rollback the change if NewValue is null

SuperJMN Oct 17, 2012 at 10:07 AM 
I also want this to support FormatString for degrees "º", for example.

SuperJMN Oct 17, 2012 at 9:30 AM 
Does it support double/float or decimal values?

andyste1 Jun 12, 2012 at 10:03 AM 
Can it be changed to support UpdateSourceTrigger=PropertyChanged when typing into the box (as opposed to using the spin buttons)? Currently it only seems to support UpdateSourceTrigger=LostFocus.

edmolko May 24, 2012 at 4:07 PM 
How can we style it? Or controltemplate it?

stricq May 13, 2012 at 9:20 PM 
IsReadOnly prevents the spinner buttons from working. This is different from the explanation of IsEditable. IsReadOnly is not a replacement for IsEditable.

aslenko Apr 27, 2012 at 7:08 PM 
Is there a way to access the underlying TextBox so I can check CaretIndex?
I can see it when debugging.

Nebuleux Apr 6, 2012 at 12:54 PM 
IsEditable has been replaced by IsReadOnly in version 1.6.0.

stricq Apr 6, 2012 at 6:07 AM 
IsEditable is not implemented.

skst Nov 14, 2011 at 8:34 PM 
Thank you. It would also be nice to have a UIntegerUpDown (NumericUpDown<uint>, of course). While we can create our own, it'd be convenient to have it in the toolkit.

CkurcK Jul 5, 2011 at 11:16 AM 
Very good !!!
It would be nice DefaultValue has to be applied to Value when reading the value rather than Nothing