//在CoerceMin加入强制判断赋值 private static object CoerceMinValue(DependencyObject d, object value) { MyValiDP g = (MyValiDP)d; double min = (double)value; if (min > g.MaxValue) { min = g.MaxValue; } return(min); }
//在CoerceMax加入强制判断赋值 private static object CoerceMaxValue(DependencyObject d, object value) { MyValiDP g = (MyValiDP)d; double max = (double)value; if (max < g.MinValue) { max = g.MinValue; } return(max); }
//在CoerceCurrent加入强制判断赋值 private static object CoerceCurrentValue(DependencyObject d, object value) { MyValiDP g = (MyValiDP)d; double current = (double)value; if (current < g.MinValue) { current = g.MinValue; } if (current > g.MaxValue) { current = g.MaxValue; } return(current); }