DecimalUpDown

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

Usage

decimalupdown.jpg

When using the DecimalUpDown 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:
decimalupdown_default.jpg
     <xctk:DecimalUpDown Value="1564.6749586" />


Floating Point:
decimalupdown_float.jpg
     <xctk:DecimalUpDown FormatString="F3" Value="1564.6749586" Increment=".001"  Maximum="200000.599" />


Currency:
decimalupdown_currency.jpg
     <xctk:DecimalUpDown FormatString="C2" Value="1564.6749586" Increment=".5" Maximum="5000.50" Minimum="50.01" />


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.

decimalupdown_watermark.jpg
     <xctk:DecimalUpDown Watermark="Enter Decimal" />


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:21 PM by DavidCPx, version 9

Comments

BoucherS Jul 29, 2013 at 7:24 PM 
Can you submit a sample for the dataTrigger binding not working ? In the discussions tab please.

dbcontext Jul 19, 2013 at 9:06 AM 
Binding to value is not working when I am using DataTriggers. It used to work in version 1.6.

BoucherS Jun 21, 2013 at 12:23 PM 
Please use the discussion tab, Discussion https://wpftoolkit.codeplex.com/discussions/447813 has been created

LaurenceBunnage Jun 21, 2013 at 8:48 AM 
I have found a couple of issues with this control (probably applies to double and int variations as well)
1) DecimalUpDown with range -x to x, i.e. -100 to 100. If you type in a negative number, the first keystroke '-' generates a FormatException.
2) DecimalUpDown with range 0.1 to 1.0. If you attempt to type 0.5, the first keystroke '0' causes the control to validate and modifies the text to 0.1, so the next keystroke '.' is ignored and the '5' is appended giving the value 0.15.
3) This may just be a personnal preference, but if you have a DecimalUpDown with an increment of 0.1 which currently holds 0.005 (by typing). Increment should go to 0.1, 02, 0.3 etc and decrement should go to 0.0, -0.1, -0.2