From 3fec1a56bf6c0184376c4987b3d5f3b0bb701463 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Fri, 27 Dec 2019 17:52:07 +0330 Subject: [PATCH 1/4] Fix poptip background --- .../HandyControl_Shared/Themes/Styles/Base/PoptipBaseStyle.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/PoptipBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/PoptipBaseStyle.xaml index 9c513359..76c1f24e 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/PoptipBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/PoptipBaseStyle.xaml @@ -12,7 +12,7 @@ - + From 35c43cabf1616c3007df8414179f2c4a8a5349c0 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Sun, 29 Dec 2019 18:50:32 +0330 Subject: [PATCH 2/4] fix #281 --- .../Themes/Styles/Base/TextBoxBaseStyle.xaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml index 88975e61..b2179bd3 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml @@ -76,7 +76,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -157,7 +157,7 @@ - + @@ -217,7 +217,7 @@ - + From efbe02c79f7d6e82dbb1031e918b86797b665546 Mon Sep 17 00:00:00 2001 From: Jinhua Chen Date: Fri, 3 Jan 2020 14:18:15 +0800 Subject: [PATCH 3/4] close 283 --- .../Controls/NumericUpDownDemoCtl.xaml | 2 + .../Controls/Input/NumericUpDown.cs | 33 +++++++++++- .../Styles/Base/NumericUpDownBaseStyle.xaml | 52 +++++++++++++------ 3 files changed, 70 insertions(+), 17 deletions(-) diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml index 77fb878d..5036e772 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml @@ -9,6 +9,7 @@ + @@ -18,6 +19,7 @@ + diff --git a/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs b/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs index 46a9ce1f..dbce3b48 100644 --- a/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs +++ b/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs @@ -31,18 +31,28 @@ namespace HandyControl.Controls { CommandBindings.Add(new CommandBinding(ControlCommands.Prev, (s, e) => { + if (IsReadOnly) + return; + Value += Increment; _textBox.Text = CurrentText; _textBox.Select(_textBox.Text.Length, 0); })); CommandBindings.Add(new CommandBinding(ControlCommands.Next, (s, e) => { + if (IsReadOnly) + return; + + Value -= Increment; _textBox.Text = CurrentText; _textBox.Select(_textBox.Text.Length, 0); })); CommandBindings.Add(new CommandBinding(ControlCommands.Clear, (s, e) => { + if (IsReadOnly) + return; + SetCurrentValue(ValueProperty, ValueBoxes.Double0Box); _textBox.Text = string.Empty; })); @@ -106,6 +116,9 @@ namespace HandyControl.Controls private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e) { + if (IsReadOnly) + return; + if (e.Key == Key.Up) { Value += Increment; @@ -122,7 +135,7 @@ namespace HandyControl.Controls { base.OnMouseWheel(e); - if (_textBox.IsFocused) + if (_textBox.IsFocused&&IsReadOnly==false) { Value += e.Delta > 0 ? Increment : -Increment; _textBox.Text = CurrentText; @@ -359,9 +372,25 @@ namespace HandyControl.Controls public bool ShowClearButton { get => (bool) GetValue(ShowClearButtonProperty); - set => SetValue(ShowClearButtonProperty, value); + set => SetValue(ShowClearButtonProperty, value); } + /// + /// 获取或设置一个值,该值指示NumericUpDown是否只读。 + /// + public bool IsReadOnly + { + get => (bool)GetValue(IsReadOnlyProperty); + set => SetValue(IsReadOnlyProperty, value); + } + + /// + /// 标识 IsReadOnly 依赖属性。 + /// + public static readonly DependencyProperty IsReadOnlyProperty = + DependencyProperty.Register(nameof(IsReadOnly), typeof(bool), typeof(NumericUpDown), new PropertyMetadata(default(bool))); + + public Func> VerifyFunc { get; set; } public virtual bool VerifyData() diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml index e41e3429..c69f0993 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml @@ -35,9 +35,9 @@ - -