HypernovaDesktop Components · docs
Binarymission
WPF › Spinner › NumericSpinner

NumericSpinner

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Controls.InputControls

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

ContentHostControlStyleGets or sets the content host control style.
IncrementGets or sets the increment.
IsReadOnlyGets or sets a value indicating whether this instance is read only.
MaximumValueGets or sets the maximum value.
MinimumValueGets or sets the minimum value.
NavigationControlStyleGets or sets the navigation control style.
NavigationVisualFillBrushGets or sets the navigation visual fill brush.
NavigationVisualOnMouseOverBorderBrushGets or sets the navigation visual on mouse-over border brush.
NavigationVisualOnMouseOverBrushGets or sets the navigation visual on mouse-over brush.
NavigationVisualStrokeGets or sets the navigation visual stroke.
ValueGets or sets the value, held to the range MinimumValue to MaximumValue; null when the box is empty.
ValueFormatGets or sets the value format.
OnApplyTemplateWhen overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate.
ValueChangedOccurs when the value changes
ContentHostControlStylePropertyThe content host control style property
IncrementPropertyThe increment property
IsReadOnlyPropertySets whether the instance is read only.
MaximumValuePropertyThe maximum value property
MinimumValuePropertyThe minimum value property
NavigationControlStylePropertyThe navigation control style property
NavigationVisualFillBrushPropertyThe navigation visual fill brush property
NavigationVisualOnMouseOverBorderBrushPropertyThe navigation visual on mouse-over border brush property
NavigationVisualOnMouseOverBrushPropertyThe navigation visual on mouse-over brush property
NavigationVisualStrokePropertyThe navigation visual stroke property
ValueChangedEventThe value changed event
ValueFormatPropertyThe value format property
ValuePropertyThe value property

Properties

ContentHostControlStyle

public Style ContentHostControlStyle

Gets or sets the content host control style.

Value. The content host control style.

Increment

public double Increment

Gets or sets the increment.

Value. The increment.

IsReadOnly

public bool IsReadOnly

Gets or sets a value indicating whether this instance is read only.

Value. true if this instance is read only; otherwise, false .

MaximumValue

public double MaximumValue

Gets or sets the maximum value.

Value. The maximum value.

MinimumValue

public double MinimumValue

Gets or sets the minimum value.

Value. The minimum value.

NavigationControlStyle

public Style NavigationControlStyle

Gets or sets the navigation control style.

Value. The navigation control style.

NavigationVisualFillBrush

public Brush NavigationVisualFillBrush

Gets or sets the navigation visual fill brush.

Value. The navigation visual fill brush.

NavigationVisualOnMouseOverBorderBrush

public Brush NavigationVisualOnMouseOverBorderBrush

Gets or sets the navigation visual on mouse-over border brush.

Value. The navigation visual on mouse over border brush.

NavigationVisualOnMouseOverBrush

public Brush NavigationVisualOnMouseOverBrush

Gets or sets the navigation visual on mouse-over brush.

Value. The navigation visual on mouse-over brush.

NavigationVisualStroke

public Brush NavigationVisualStroke

Gets or sets the navigation visual stroke.

Value. The navigation visual stroke.

Value

public double? Value

Gets or sets the value, held to the range MinimumValue to MaximumValue; null when the box is empty.

Value. The value.

ValueFormat

public string ValueFormat

Gets or sets the value format.

Value. The value format.

Methods

OnApplyTemplate

public override void OnApplyTemplate()

When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate.

Events

ValueChanged

public event RoutedEventHandler ValueChanged

Occurs when the value changes

Fields

ContentHostControlStyleProperty

public static readonly DependencyProperty ContentHostControlStyleProperty

The content host control style property

IncrementProperty

public static readonly DependencyProperty IncrementProperty

The increment property

IsReadOnlyProperty

public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register( "IsReadOnly", typeof(bool), typeof(NumericSpinner), new PropertyMetadata(default(bool), (o, args)

Sets whether the instance is read only.

MaximumValueProperty

public static readonly DependencyProperty MaximumValueProperty

The maximum value property

MinimumValueProperty

public static readonly DependencyProperty MinimumValueProperty

The minimum value property

NavigationControlStyleProperty

public static readonly DependencyProperty NavigationControlStyleProperty

The navigation control style property

NavigationVisualFillBrushProperty

public static readonly DependencyProperty NavigationVisualFillBrushProperty

The navigation visual fill brush property

NavigationVisualOnMouseOverBorderBrushProperty

public static readonly DependencyProperty NavigationVisualOnMouseOverBorderBrushProperty

The navigation visual on mouse-over border brush property

NavigationVisualOnMouseOverBrushProperty

public static readonly DependencyProperty NavigationVisualOnMouseOverBrushProperty

The navigation visual on mouse-over brush property

NavigationVisualStrokeProperty

public static readonly DependencyProperty NavigationVisualStrokeProperty

The navigation visual stroke property

ValueChangedEvent

public static readonly RoutedEvent ValueChangedEvent

The value changed event

ValueFormatProperty

public static readonly DependencyProperty ValueFormatProperty = DependencyProperty.Register("ValueFormat", typeof(string), typeof(NumericSpinner), new UIPropertyMetadata("0", (o, e)

The value format property

ValueProperty

public static readonly DependencyProperty ValueProperty

The value property