rename StringFormat property
This commit is contained in:
1 parent
f28fa3ad84
commit
b4d26dd2fa
2 files changed
+11
-27
No files matched your search
@@ -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<double> e) => RaiseEvent(e);
|
||||
|
||||
@@ -333,16 +323,16 @@ namespace HandyControl.Controls
|
||||
/// <summary>
|
||||
/// 指示要显示的数字的格式
|
||||
/// </summary>
|
||||
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)));
|
||||
|
||||
/// <summary>
|
||||
/// 指示要显示的数字的格式,这将会覆盖 <see cref="DecimalPlaces"/> 属性
|
||||
/// </summary>
|
||||
public string StringFormat
|
||||
public string ValueFormat
|
||||
{
|
||||
get { return (string)GetValue(StringFormatProperty); }
|
||||
set { SetValue(StringFormatProperty, value); }
|
||||
get => (string) GetValue(ValueFormatProperty);
|
||||
set => SetValue(ValueFormatProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user