From b4d26dd2fad8f5c3a3f1b0d83c5cd8faed0ed432 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Wed, 25 Nov 2020 21:45:16 +0800 Subject: [PATCH] rename StringFormat property --- .../Controls/NumericUpDownDemoCtl.xaml | 8 +---- .../Controls/Input/NumericUpDown.cs | 30 +++++++------------ 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml index 433afce9..e09deb85 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml @@ -15,13 +15,7 @@ - - + diff --git a/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs b/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs index d2e4dbd4..cc544656 100644 --- a/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs +++ b/src/Shared/HandyControl_Shared/Controls/Input/NumericUpDown.cs @@ -153,21 +153,11 @@ namespace HandyControl.Controls } } - private string CurrentText - { - get - { - if (string.IsNullOrWhiteSpace(StringFormat)) - { - return DecimalPlaces.HasValue ? Value.ToString($"#0.{new string('0', DecimalPlaces.Value)}") : - Value.ToString("#0"); - } - else - { - return Value.ToString(StringFormat); - } - } - } + private string CurrentText => string.IsNullOrWhiteSpace(ValueFormat) + ? DecimalPlaces.HasValue + ? Value.ToString($"#0.{new string('0', DecimalPlaces.Value)}") + : Value.ToString("#0") + : Value.ToString(ValueFormat); protected virtual void OnValueChanged(FunctionEventArgs e) => RaiseEvent(e); @@ -333,16 +323,16 @@ namespace HandyControl.Controls /// /// 指示要显示的数字的格式 /// - public static readonly DependencyProperty StringFormatProperty = - DependencyProperty.Register("StringFormat", typeof(string), typeof(NumericUpDown), new PropertyMetadata(default(string))); + public static readonly DependencyProperty ValueFormatProperty = DependencyProperty.Register( + "ValueFormat", typeof(string), typeof(NumericUpDown), new PropertyMetadata(default(string))); /// /// 指示要显示的数字的格式,这将会覆盖 属性 /// - public string StringFormat + public string ValueFormat { - get { return (string)GetValue(StringFormatProperty); } - set { SetValue(StringFormatProperty, value); } + get => (string) GetValue(ValueFormatProperty); + set => SetValue(ValueFormatProperty, value); } ///