|
@@ -41,6 +41,7 @@ namespace PDF_Office.CustomControl
|
|
|
get { return (double)GetValue(ValueProperty); }
|
|
|
set
|
|
|
{
|
|
|
+ SetValue(ValueProperty, value);
|
|
|
if (value > Maximum)
|
|
|
{
|
|
|
SetValue(ValueProperty, Maximum);
|
|
@@ -58,9 +59,17 @@ namespace PDF_Office.CustomControl
|
|
|
}
|
|
|
|
|
|
public static readonly DependencyProperty ValueProperty =
|
|
|
- DependencyProperty.Register("Value", typeof(double), typeof(NumericUpDown), new PropertyMetadata(0.0));
|
|
|
-
|
|
|
+ DependencyProperty.Register("Value", typeof(double), typeof(NumericUpDown), new PropertyMetadata(0.0, SelectedItemSourcePropertyChanged));
|
|
|
|
|
|
+ private static void SelectedItemSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
|
+ {
|
|
|
+ var control = d as NumericUpDown;
|
|
|
+ var value = (double)e.NewValue;
|
|
|
+ if (control != null)
|
|
|
+ {
|
|
|
+ control.TextBox_Num.Text = Convert.ToString(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 最大值
|
|
|
/// </summary>
|
|
@@ -167,13 +176,14 @@ namespace PDF_Office.CustomControl
|
|
|
|
|
|
private void TextBox_Num_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
{
|
|
|
- int num = 0;
|
|
|
- if (this.TextBox_Num.Text == "" || !int.TryParse(this.TextBox_Num.Text,out num))
|
|
|
+ //int.TryParse("30.0000610351563"),字符串有小数点,会转换失败
|
|
|
+ double num = 0;
|
|
|
+ if (this.TextBox_Num.Text == "" || !double.TryParse(this.TextBox_Num.Text,out num))
|
|
|
{
|
|
|
this.TextBox_Num.Text = Minimum.ToString();
|
|
|
}
|
|
|
Text = this.TextBox_Num.Text;
|
|
|
- Value = int.Parse(this.TextBox_Num.Text);
|
|
|
+ Value = (int)double.Parse(this.TextBox_Num.Text);
|
|
|
}
|
|
|
|
|
|
private void CountTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
|