public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(int), typeof(QuantityUpDown), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValueChanged, CoerceValue));
public int Value
{
get { return (int) GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
private static object CoerceValue(DependencyObject d, object basevalue)
{
//Verifies value is not outside Minimum or Maximum
QuantityUpDown upDown = d as QuantityUpDown;
if (upDown == null)
return basevalue;
if ((int)basevalue
Подробнее здесь: [url]https://stackoverflow.com/questions/41549918/how-do-i-handle-dependencyproperty-overflow-situations[/url]
public int Value { get { return (int) GetValue(ValueProperty); } set { SetValue(ValueProperty, value); } }
private static object CoerceValue(DependencyObject d, object basevalue) { //Verifies value is not outside Minimum or Maximum QuantityUpDown upDown = d as QuantityUpDown; if (upDown == null) return basevalue;