fix: NumericUpDown can not input decimal point.

This commit is contained in:
NaBian 2023-01-17 18:25:42 +08:00
parent 689d5e7a80
commit d0c14de606

View File

@ -82,6 +82,10 @@ public class NumericUpDown : Control
{
SetCurrentValue(ValueProperty, value);
}
else
{
SetText(true);
}
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
@ -116,6 +120,7 @@ public class NumericUpDown : Control
if (_textBox.IsFocused && !IsReadOnly)
{
Value += e.Delta > 0 ? Increment : -Increment;
SetText(true);
e.Handled = true;
}
}
@ -164,9 +169,9 @@ public class NumericUpDown : Control
});
}
private void SetText()
private void SetText(bool force = false)
{
if (_textBox != null)
if (_textBox != null && (!_textBox.IsFocused || force))
{
_textBox.Text = CurrentText;
_textBox.Select(_textBox.Text.Length, 0);