rename StringFormat property
This commit is contained in:
1 parent
f28fa3ad84
commit
b4d26dd2fa
2 files changed
+11
-27
No files matched your search
@@ -15,13 +15,7 @@
|
|||||||
<hc:NumericUpDown hc:InfoElement.Title="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr1}}" Margin="0,32,0,0" Style="{StaticResource NumericUpDownExtend}"/>
|
<hc:NumericUpDown hc:InfoElement.Title="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr1}}" Margin="0,32,0,0" Style="{StaticResource NumericUpDownExtend}"/>
|
||||||
<hc:NumericUpDown hc:InfoElement.Placeholder="{ex:Lang Key={x:Static langs:LangKeys.PlsEnterContent}}" hc:InfoElement.Title="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr1}}" Margin="0,32,0,0" hc:InfoElement.Necessary="True" Style="{StaticResource NumericUpDownExtend}"/>
|
<hc:NumericUpDown hc:InfoElement.Placeholder="{ex:Lang Key={x:Static langs:LangKeys.PlsEnterContent}}" hc:InfoElement.Title="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr1}}" Margin="0,32,0,0" hc:InfoElement.Necessary="True" Style="{StaticResource NumericUpDownExtend}"/>
|
||||||
<hc:NumericUpDown Width="380" hc:InfoElement.TitleWidth="140" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr3}}" Style="{StaticResource NumericUpDownExtend}" Margin="0,32,0,0"/>
|
<hc:NumericUpDown Width="380" hc:InfoElement.TitleWidth="140" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr3}}" Style="{StaticResource NumericUpDownExtend}" Margin="0,32,0,0"/>
|
||||||
<hc:NumericUpDown Width="380" hc:InfoElement.TitleWidth="140" hc:InfoElement.Placeholder="{ex:Lang Key={x:Static langs:LangKeys.PlsEnterContent}}" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr3}}" Style="{StaticResource NumericUpDownExtend}" hc:InfoElement.Necessary="True" Margin="0,32,0,0"/>
|
<hc:NumericUpDown ValueFormat="N2" Maximum="100000" Value="10000" Width="380" hc:InfoElement.TitleWidth="140" hc:InfoElement.Placeholder="{ex:Lang Key={x:Static langs:LangKeys.PlsEnterContent}}" hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr3}}" Style="{StaticResource NumericUpDownExtend}" hc:InfoElement.Necessary="True" Margin="0,32,0,0"/>
|
||||||
<hc:NumericUpDown Margin="0,32,0,0"
|
|
||||||
hc:InfoElement.TitlePlacement="Left"
|
|
||||||
hc:InfoElement.Title="{ex:Lang Key={x:Static langs:LangKeys.TitleDemoStr3}}"
|
|
||||||
Style="{StaticResource NumericUpDownExtend}"
|
|
||||||
Value="1024"
|
|
||||||
StringFormat="N2" />
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Margin="32,0,0,0">
|
<StackPanel Margin="32,0,0,0">
|
||||||
<hc:NumericUpDown Name="NumericUpDownCustomVerify" ShowClearButton="True" Style="{StaticResource NumericUpDownPlus}"/>
|
<hc:NumericUpDown Name="NumericUpDownCustomVerify" ShowClearButton="True" Style="{StaticResource NumericUpDownPlus}"/>
|
||||||
|
|||||||
@@ -153,21 +153,11 @@ namespace HandyControl.Controls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string CurrentText
|
private string CurrentText => string.IsNullOrWhiteSpace(ValueFormat)
|
||||||
{
|
? DecimalPlaces.HasValue
|
||||||
get
|
? Value.ToString($"#0.{new string('0', DecimalPlaces.Value)}")
|
||||||
{
|
: Value.ToString("#0")
|
||||||
if (string.IsNullOrWhiteSpace(StringFormat))
|
: Value.ToString(ValueFormat);
|
||||||
{
|
|
||||||
return DecimalPlaces.HasValue ? Value.ToString($"#0.{new string('0', DecimalPlaces.Value)}") :
|
|
||||||
Value.ToString("#0");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Value.ToString(StringFormat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnValueChanged(FunctionEventArgs<double> e) => RaiseEvent(e);
|
protected virtual void OnValueChanged(FunctionEventArgs<double> e) => RaiseEvent(e);
|
||||||
|
|
||||||
@@ -333,16 +323,16 @@ namespace HandyControl.Controls
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指示要显示的数字的格式
|
/// 指示要显示的数字的格式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly DependencyProperty StringFormatProperty =
|
public static readonly DependencyProperty ValueFormatProperty = DependencyProperty.Register(
|
||||||
DependencyProperty.Register("StringFormat", typeof(string), typeof(NumericUpDown), new PropertyMetadata(default(string)));
|
"ValueFormat", typeof(string), typeof(NumericUpDown), new PropertyMetadata(default(string)));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指示要显示的数字的格式,这将会覆盖 <see cref="DecimalPlaces"/> 属性
|
/// 指示要显示的数字的格式,这将会覆盖 <see cref="DecimalPlaces"/> 属性
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string StringFormat
|
public string ValueFormat
|
||||||
{
|
{
|
||||||
get { return (string)GetValue(StringFormatProperty); }
|
get => (string) GetValue(ValueFormatProperty);
|
||||||
set { SetValue(StringFormatProperty, value); }
|
set => SetValue(ValueFormatProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in new issue
Block a user