From 132670dba6031679cacc33349e821039f7799664 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Fri, 8 May 2020 23:47:35 +0800 Subject: [PATCH] fixed a bug of NumericUpDown --- .../Controls/Input/NumericUpDown.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs b/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs index d2e2b08b..53975dd3 100644 --- a/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs +++ b/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs @@ -74,7 +74,7 @@ namespace HandyControl.Controls if (_textBox != null) { TextCompositionManager.RemovePreviewTextInputHandler(_textBox, PreviewTextInputHandler); - _textBox.TextChanged -= _textBox_TextChanged; + _textBox.TextChanged -= TextBox_TextChanged; _textBox.PreviewKeyDown -= TextBox_PreviewKeyDown; _textBox.LostFocus -= TextBox_LostFocus; } @@ -87,18 +87,22 @@ namespace HandyControl.Controls if (_textBox != null) { TextCompositionManager.AddPreviewTextInputHandler(_textBox, PreviewTextInputHandler); - _textBox.TextChanged += _textBox_TextChanged; + _textBox.TextChanged += TextBox_TextChanged; _textBox.PreviewKeyDown += TextBox_PreviewKeyDown; _textBox.LostFocus += TextBox_LostFocus; _textBox.Text = CurrentText; } } - private void _textBox_TextChanged(object sender, TextChangedEventArgs e) => UpdateData(); + private void TextBox_TextChanged(object sender, TextChangedEventArgs e) => UpdateData(); private void UpdateData() { - if (!VerifyData()) return; + if (!VerifyData()) + { + _updateText = true; + return; + } if (double.TryParse(_textBox.Text, out var value)) { _updateText = false;