fix: NumericUpDown can not input decimal point.

This commit is contained in:
NaBian committed 2023-01-17 18:25:42 +08:00
1 parent 689d5e7a80
commit d0c14de606
1 file changed
+7 -2
@@ -82,6 +82,10 @@ public class NumericUpDown : Control
{ {
SetCurrentValue(ValueProperty, value); SetCurrentValue(ValueProperty, value);
} }
else
{
SetText(true);
}
} }
private void TextBox_TextChanged(object sender, TextChangedEventArgs e) private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
@@ -116,6 +120,7 @@ public class NumericUpDown : Control
if (_textBox.IsFocused && !IsReadOnly) if (_textBox.IsFocused && !IsReadOnly)
{ {
Value += e.Delta > 0 ? Increment : -Increment; Value += e.Delta > 0 ? Increment : -Increment;
SetText(true);
e.Handled = 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.Text = CurrentText;
_textBox.Select(_textBox.Text.Length, 0); _textBox.Select(_textBox.Text.Length, 0);