Как мне справиться с ситуациями переполнения DependencyProperty?C#

Место общения программистов C#
Anonymous
Как мне справиться с ситуациями переполнения DependencyProperty?

Сообщение Anonymous »

У меня есть UserControl и int DependencyProperty под названием Value. Это привязано к текстовому вводу в UserControl.

Код: Выделить всё

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]

Вернуться в «C#»