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 / Events

Property Description
AllowSpin Gets/Sets the ability to perform increment/decrement operations via the keyboard, button spinners, or mouse wheel.
CultureInfo Gets/Sets the current CultureInfo.
DefaultValue Get/Sets the value to use when the Value is null and an increment/decrement operation is performed.
FormatString Gets/Sets the dispaly format of the Value.
Increment Specifies the amount in which to increment the value.
IsReadOnly Gets/Sets a value indicating whether the control is read only.
Maximum Gets/Sets the maximum allowed value.
Mimum Gets/Sets the minimum allowed value.
MouseWheelActiveOnFocus Gets/Sets if the control must have focus in order for the mouse wheel to incement/decrement the value. True by default.
SelectAllOnGotFocus If set to true, all text is selected when control gets focus.
ShowButtonSpinner Gets/Sets if the button spinners are visible.
Text Gets/Sets the formated string representation of the value.
TextAlignment Gets/Sets the alignment of the Text.
Value Gets/Sets the numeric value.
Watermark Gets/Sets the object to use as a watermark if the Value is null.
WatermarkTemplate Gets/Sets the DatTemplate to use for the Watermark.


Event Description
ValueChanged Occurs when the Value changes.

Last edited May 27, 2013 at 8:23 PM by DavidCPx, version 8

Comments

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

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

juliangold Jul 8, 2013 at 11:05 AM 
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 1: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 1:48 PM 
MRothaus, This issue has been created based on your need: http://wpftoolkit.codeplex.com/workitem/19335

MRothaus Feb 9, 2013 at 4: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 12:04 PM 
This will be fixed in v2.0.

Epsil0neR Feb 5, 2013 at 9: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 12: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 11:47 AM 
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 7: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 9: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 9:07 AM 
I also want this to support FormatString for degrees "º", for example.

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

andyste1 Jun 12, 2012 at 9: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 3:07 PM 
How can we style it? Or controltemplate it?

stricq May 13, 2012 at 8: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 6: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 11:54 AM 
IsEditable has been replaced by IsReadOnly in version 1.6.0.

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

skst Nov 14, 2011 at 7: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 10:16 AM 
Very good !!!
It would be nice DefaultValue has to be applied to Value when reading the value rather than Nothing