Class NumericUpDown
Control that represents a TextBox with button spinners that allow incrementing and decrementing numeric values.
[TemplatePart("PART_Spinner", typeof(Spinner))]
[TemplatePart("PART_TextBox", typeof(TextBox), IsRequired = true)]
public class NumericUpDown : TemplatedControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
- Inheritance
-
NumericUpDown
- Implements
- Inherited Members
- Extension Methods
Constructors
NumericUpDown()
Initializes new instance of NumericUpDown class.
public NumericUpDown()
Fields
AllowSpinProperty
Defines the AllowSpin property.
public static readonly StyledProperty<bool> AllowSpinProperty
Field Value
ButtonSpinnerLocationProperty
Defines the ButtonSpinnerLocation property.
public static readonly StyledProperty<Location> ButtonSpinnerLocationProperty
Field Value
ClipValueToMinMaxProperty
Defines the ClipValueToMinMax property.
public static readonly StyledProperty<bool> ClipValueToMinMaxProperty
Field Value
FormatStringProperty
Defines the FormatString property.
public static readonly StyledProperty<string> FormatStringProperty
Field Value
HorizontalContentAlignmentProperty
Defines the HorizontalContentAlignment property.
public static readonly StyledProperty<HorizontalAlignment> HorizontalContentAlignmentProperty
Field Value
IncrementProperty
Defines the Increment property.
public static readonly StyledProperty<decimal> IncrementProperty
Field Value
InnerLeftContentProperty
Defines the InnerLeftContent property
public static readonly StyledProperty<object?> InnerLeftContentProperty
Field Value
InnerRightContentProperty
Defines the InnerRightContent property
public static readonly StyledProperty<object?> InnerRightContentProperty
Field Value
IsReadOnlyProperty
Defines the IsReadOnly property.
public static readonly StyledProperty<bool> IsReadOnlyProperty
Field Value
MaximumProperty
Defines the Maximum property.
public static readonly StyledProperty<decimal> MaximumProperty
Field Value
MinimumProperty
Defines the Minimum property.
public static readonly StyledProperty<decimal> MinimumProperty
Field Value
NumberFormatProperty
Defines the NumberFormat property.
public static readonly StyledProperty<NumberFormatInfo?> NumberFormatProperty
Field Value
ParsingNumberStyleProperty
Defines the ParsingNumberStyle property.
public static readonly StyledProperty<NumberStyles> ParsingNumberStyleProperty
Field Value
ShowButtonSpinnerProperty
Defines the ShowButtonSpinner property.
public static readonly StyledProperty<bool> ShowButtonSpinnerProperty
Field Value
TextAlignmentProperty
Defines the TextAlignment property
public static readonly StyledProperty<TextAlignment> TextAlignmentProperty
Field Value
TextConverterProperty
Defines the TextConverter property.
public static readonly StyledProperty<IValueConverter?> TextConverterProperty
Field Value
TextProperty
Defines the Text property.
public static readonly StyledProperty<string?> TextProperty
Field Value
ValueChangedEvent
Defines the ValueChanged event.
public static readonly RoutedEvent<NumericUpDownValueChangedEventArgs> ValueChangedEvent
Field Value
ValueProperty
Defines the Value property.
public static readonly StyledProperty<decimal?> ValueProperty
Field Value
VerticalContentAlignmentProperty
Defines the VerticalContentAlignment property.
public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty
Field Value
WatermarkProperty
Defines the Watermark property.
public static readonly StyledProperty<string?> WatermarkProperty
Field Value
Properties
AllowSpin
Gets or sets the ability to perform increment/decrement operations via the keyboard, button spinners, or mouse wheel.
public bool AllowSpin { get; set; }
Property Value
ButtonSpinnerLocation
Gets or sets current location of the ButtonSpinner.
public Location ButtonSpinnerLocation { get; set; }
Property Value
ClipValueToMinMax
Gets or sets if the value should be clipped when minimum/maximum is reached.
public bool ClipValueToMinMax { get; set; }
Property Value
FormatString
Gets or sets the display format of the Value.
public string FormatString { get; set; }
Property Value
HorizontalContentAlignment
Gets or sets the horizontal alignment of the content within the control.
public HorizontalAlignment HorizontalContentAlignment { get; set; }
Property Value
Increment
Gets or sets the amount in which to increment the Value.
public decimal Increment { get; set; }
Property Value
InnerLeftContent
Gets or sets custom content that is positioned on the left side of the text layout box
public object? InnerLeftContent { get; set; }
Property Value
InnerRightContent
Gets or sets custom content that is positioned on the right side of the text layout box
public object? InnerRightContent { get; set; }
Property Value
IsReadOnly
Gets or sets if the control is read only.
public bool IsReadOnly { get; set; }
Property Value
Maximum
Gets or sets the maximum allowed value.
public decimal Maximum { get; set; }
Property Value
Minimum
Gets or sets the minimum allowed value.
public decimal Minimum { get; set; }
Property Value
NumberFormat
Gets or sets the current NumberFormatInfo
public NumberFormatInfo? NumberFormat { get; set; }
Property Value
ParsingNumberStyle
Gets or sets the parsing style (AllowLeadingWhite, Float, AllowHexSpecifier, ...). By default, Any. Note that Hex style does not work with decimal. For hexadecimal display, use TextConverter.
public NumberStyles ParsingNumberStyle { get; set; }
Property Value
ShowButtonSpinner
Gets or sets a value indicating whether the spin buttons should be shown.
public bool ShowButtonSpinner { get; set; }
Property Value
Text
Gets or sets the formatted string representation of the value.
public string? Text { get; set; }
Property Value
TextAlignment
Gets or sets the TextAlignment of the NumericUpDown
public TextAlignment TextAlignment { get; set; }
Property Value
TextConverter
Gets or sets the custom bidirectional Text-Value converter. Non-null converter overrides ParsingNumberStyle, providing finer control over string representation of the underlying value.
public IValueConverter? TextConverter { get; set; }
Property Value
Value
Gets or sets the value.
public decimal? Value { get; set; }
Property Value
VerticalContentAlignment
Gets or sets the vertical alignment of the content within the control.
public VerticalAlignment VerticalContentAlignment { get; set; }
Property Value
Watermark
Gets or sets the object to use as a watermark if the Value is null.
public string? Watermark { get; set; }
Property Value
Methods
OnApplyTemplate(TemplateAppliedEventArgs)
Called when the control's template is applied. In simple terms, this means the method is called just before the control is displayed.
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
Parameters
e
TemplateAppliedEventArgsThe event args.
OnCoerceIncrement(decimal)
Called when the Increment property has to be coerced.
protected virtual decimal OnCoerceIncrement(decimal baseValue)
Parameters
baseValue
decimalThe value.
Returns
OnCoerceMaximum(decimal)
Called when the Maximum property has to be coerced.
protected virtual decimal OnCoerceMaximum(decimal baseValue)
Parameters
baseValue
decimalThe value.
Returns
OnCoerceMinimum(decimal)
Called when the Minimum property has to be coerced.
protected virtual decimal OnCoerceMinimum(decimal baseValue)
Parameters
baseValue
decimalThe value.
Returns
OnCoerceValue(decimal?)
Called when the Value property has to be coerced.
protected virtual decimal? OnCoerceValue(decimal? baseValue)
Parameters
baseValue
decimal?The value.
Returns
OnFormatStringChanged(string?, string?)
Called when the FormatString property value changed.
protected virtual void OnFormatStringChanged(string? oldValue, string? newValue)
Parameters
OnGotFocus(GotFocusEventArgs)
Called before the GotFocus event occurs.
protected override void OnGotFocus(GotFocusEventArgs e)
Parameters
e
GotFocusEventArgsThe event args.
OnIncrementChanged(decimal, decimal)
Called when the Increment property value changed.
protected virtual void OnIncrementChanged(decimal oldValue, decimal newValue)
Parameters
OnIsReadOnlyChanged(bool, bool)
Called when the IsReadOnly property value changed.
protected virtual void OnIsReadOnlyChanged(bool oldValue, bool newValue)
Parameters
OnKeyDown(KeyEventArgs)
Called before the KeyDown event occurs.
protected override void OnKeyDown(KeyEventArgs e)
Parameters
e
KeyEventArgsThe event args.
OnLostFocus(RoutedEventArgs)
Called before the LostFocus event occurs.
protected override void OnLostFocus(RoutedEventArgs e)
Parameters
e
RoutedEventArgsThe event args.
OnMaximumChanged(decimal, decimal)
Called when the Maximum property value changed.
protected virtual void OnMaximumChanged(decimal oldValue, decimal newValue)
Parameters
OnMinimumChanged(decimal, decimal)
Called when the Minimum property value changed.
protected virtual void OnMinimumChanged(decimal oldValue, decimal newValue)
Parameters
OnNumberFormatChanged(NumberFormatInfo?, NumberFormatInfo?)
Called when the NumberFormat property value changed.
protected virtual void OnNumberFormatChanged(NumberFormatInfo? oldValue, NumberFormatInfo? newValue)
Parameters
oldValue
NumberFormatInfoThe old value.
newValue
NumberFormatInfoThe new value.
OnSpin(SpinEventArgs)
Raises the OnSpin event when spinning is initiated by the end-user.
protected virtual void OnSpin(SpinEventArgs e)
Parameters
e
SpinEventArgsThe event args.
OnTextChanged(string?, string?)
Called when the Text property value changed.
protected virtual void OnTextChanged(string? oldValue, string? newValue)
Parameters
OnTextConverterChanged(IValueConverter?, IValueConverter?)
Called when the Text property value changed.
protected virtual void OnTextConverterChanged(IValueConverter? oldValue, IValueConverter? newValue)
Parameters
oldValue
IValueConverterThe old value.
newValue
IValueConverterThe new value.
OnValueChanged(decimal?, decimal?)
Called when the Value property value changed.
protected virtual void OnValueChanged(decimal? oldValue, decimal? newValue)
Parameters
RaiseValueChangedEvent(decimal?, decimal?)
Raises the ValueChanged event.
protected virtual void RaiseValueChangedEvent(decimal? oldValue, decimal? newValue)
Parameters
UpdateDataValidation(AvaloniaProperty, BindingValueType, Exception?)
Called to update the validation state for properties for which data validation is enabled.
protected override void UpdateDataValidation(AvaloniaProperty property, BindingValueType state, Exception? error)
Parameters
property
AvaloniaPropertyThe property.
state
BindingValueTypeThe current data binding state.
error
ExceptionThe current data binding error, if any.
Events
Spinned
public event EventHandler<SpinEventArgs>? Spinned
Event Type
ValueChanged
Raised when the Value changes.
public event EventHandler<NumericUpDownValueChangedEventArgs>? ValueChanged