Merge pull request #407 from HandyOrg/pr/395

Pr/395
This commit is contained in:
NaBian authored and GitHub committed 2020-06-18 23:23:13 +08:00
commit 6d16c9965a
1 file changed
+12 -7
@@ -1,4 +1,4 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
@@ -178,11 +178,7 @@ namespace HandyControl.Controls
{ {
var ctl = (NumericUpDown)d; var ctl = (NumericUpDown)d;
var v = (double)e.NewValue; var v = (double)e.NewValue;
if (ctl._updateText && ctl._textBox != null) ctl.SetText();
{
ctl._textBox.Text = ctl.CurrentText;
ctl._textBox.Select(ctl._textBox.Text.Length, 0);
}
ctl.OnValueChanged(new FunctionEventArgs<double>(ValueChangedEvent, ctl) ctl.OnValueChanged(new FunctionEventArgs<double>(ValueChangedEvent, ctl)
{ {
@@ -190,6 +186,15 @@ namespace HandyControl.Controls
}); });
} }
private void SetText()
{
if (_updateText && _textBox != null)
{
_textBox.Text = CurrentText;
_textBox.Select(_textBox.Text.Length, 0);
}
}
private static object CoerceValue(DependencyObject d, object basevalue) private static object CoerceValue(DependencyObject d, object basevalue)
{ {
var ctl = (NumericUpDown)d; var ctl = (NumericUpDown)d;
@@ -205,7 +210,7 @@ namespace HandyControl.Controls
{ {
ctl.Value = maximum; ctl.Value = maximum;
} }
ctl.SetText();
return num > maximum ? maximum : num; return num > maximum ? maximum : num;
} }