NumericSpinner
A custom control to support spinning numbers up/down.
public class NumericSpinner : Control
Inherits from / implements: Control
Remarks
How this control works. The template supplies a text box and two repeat buttons; the control owns the number. The text box shows Value formatted with ValueFormat in the current culture, or an edit in progress, and nothing else. The range is enforced by coercion. A Value set outside MinimumValue to MaximumValue reads back as the nearer limit, and WPF remembers the value that was asked for, so widening the range later lets it through. A step past a limit lands on the limit rather than being refused. Typing. Input is filtered, on typing and on paste, to text that could still become a number in the current culture: digits, group separators, one decimal separator, and a minus sign only when the range goes below zero. What was typed becomes the value on Enter, when the box loses focus, and before any step; empty text clears the value to null , and Escape puts the text back. Text that still shows the current value is not read back, so a value displayed rounded (a ValueFormat of "0" or "N0" ) is not rounded by tabbing through the control. Keyboard and wheel. Up and Page Up step up, Down and Page Down step down, and Ctrl+Home and Ctrl+End go to the limits. The mouse wheel steps only while the text box has keyboard focus, so scrolling a page past the control does not change it. IsReadOnly stops all of these, and the buttons.
Members at a glance
ContentHostControlStyle | Gets or sets the content host control style. |
Increment | Gets or sets the increment. |
IsReadOnly | Gets or sets a value indicating whether this instance is read only. |
MaximumValue | Gets or sets the maximum value. |
MinimumValue | Gets or sets the minimum value. |
NavigationControlStyle | Gets or sets the navigation control style. |
NavigationVisualFillBrush | Gets or sets the navigation visual fill brush. |
NavigationVisualOnMouseOverBorderBrush | Gets or sets the navigation visual on mouse-over border brush. |
NavigationVisualOnMouseOverBrush | Gets or sets the navigation visual on mouse-over brush. |
NavigationVisualStroke | Gets or sets the navigation visual stroke. |
Value | Gets or sets the value, held to the range MinimumValue to MaximumValue; null when the box is empty. |
ValueFormat | Gets or sets the value format. |
OnApplyTemplate | When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate. |
ValueChanged | Occurs when the value changes |
ContentHostControlStyleProperty | The content host control style property |
IncrementProperty | The increment property |
IsReadOnlyProperty | Sets whether the instance is read only. |
MaximumValueProperty | The maximum value property |
MinimumValueProperty | The minimum value property |
NavigationControlStyleProperty | The navigation control style property |
NavigationVisualFillBrushProperty | The navigation visual fill brush property |
NavigationVisualOnMouseOverBorderBrushProperty | The navigation visual on mouse-over border brush property |
NavigationVisualOnMouseOverBrushProperty | The navigation visual on mouse-over brush property |
NavigationVisualStrokeProperty | The navigation visual stroke property |
ValueChangedEvent | The value changed event |
ValueFormatProperty | The value format property |
ValueProperty | The value property |
Properties
ContentHostControlStyle
Gets or sets the content host control style.
Value. The content host control style.
Increment
Gets or sets the increment.
Value. The increment.
IsReadOnly
Gets or sets a value indicating whether this instance is read only.
Value. true if this instance is read only; otherwise, false .
MaximumValue
Gets or sets the maximum value.
Value. The maximum value.
MinimumValue
Gets or sets the minimum value.
Value. The minimum value.
Value
Gets or sets the value, held to the range MinimumValue to MaximumValue; null when the box is empty.
Value. The value.
ValueFormat
Gets or sets the value format.
Value. The value format.
Methods
OnApplyTemplate
When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate.
Events
ValueChanged
Occurs when the value changes
Fields
ContentHostControlStyleProperty
The content host control style property
IncrementProperty
The increment property
IsReadOnlyProperty
Sets whether the instance is read only.
MaximumValueProperty
The maximum value property
MinimumValueProperty
The minimum value property
ValueChangedEvent
The value changed event
ValueFormatProperty
The value format property
ValueProperty
The value property