From 0062c68847eaea4b3c8b2f83e995e06ab993ac3a Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Tue, 4 Feb 2020 12:53:29 +0800 Subject: [PATCH] fixed #189 --- .../UserControl/Controls/NumericUpDownDemoCtl.xaml | 2 +- .../Controls/Input/NumericUpDown.cs | 8 +++++++- .../Themes/Styles/Base/NumericUpDownBaseStyle.xaml | 12 ++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml index 5036e772..7ac08446 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml @@ -7,7 +7,7 @@ - + diff --git a/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs b/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs index 992adabf..d2e2b08b 100644 --- a/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs +++ b/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs @@ -13,18 +13,23 @@ namespace HandyControl.Controls /// 数值选择控件 /// [TemplatePart(Name = ElementTextBox, Type = typeof(TextBox))] + [TemplatePart(Name = ElementErrorTip, Type = typeof(UIElement))] public class NumericUpDown : Control, IDataInput { #region Constants private const string ElementTextBox = "PART_TextBox"; + private const string ElementErrorTip = "PART_ErrorTip"; + #endregion Constants #region Data private TextBox _textBox; + private UIElement _errorTip; + private bool _updateText; #endregion Data @@ -77,6 +82,7 @@ namespace HandyControl.Controls base.OnApplyTemplate(); _textBox = GetTemplateChild(ElementTextBox) as TextBox; + _errorTip = GetTemplateChild(ElementErrorTip) as UIElement; if (_textBox != null) { @@ -105,7 +111,7 @@ namespace HandyControl.Controls private void TextBox_LostFocus(object sender, RoutedEventArgs e) { - if (IsError) return; + if (IsError && _errorTip != null) return; _textBox.Text = CurrentText; } diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml index c69f0993..ae0f1b99 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml @@ -158,10 +158,10 @@ - + - + @@ -169,7 +169,7 @@ - + @@ -225,10 +225,10 @@ - + - + @@ -236,7 +236,7 @@ - +