private static void OnValueChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            MyDependencyObject control = (MyDependencyObject)obj;

            RoutedPropertyChangedEventArgs <int> e = new RoutedPropertyChangedEventArgs <int>((int)args.OldValue, (int)args.NewValue, ValueChangedEvent);

            control.OnValueChanged(e);
        }
        private static object CoerceValue(DependencyObject element, object value)
        {
            int newValue = (int)value;
            MyDependencyObject control = (MyDependencyObject)element;

            newValue = Math.Max(control.Minimum, Math.Min(control.Maximum, newValue));

            return(newValue);
        }
Пример #3
0
        static void Main()
        {
            MyDependencyObject obj = new MyDependencyObject();

            obj.ValueChanged += (sender, e) =>
            {
                Console.WriteLine("value changed from {0} to {1}", e.OldValue, e.NewValue);
            };
            obj.Value = 33;
            Console.WriteLine(obj.Maximum);
            obj.Value = 210;
            Console.WriteLine(obj.Value);


            object value = obj.GetValue(MyDependencyObject.ValueProperty);

            Console.WriteLine(value);
        }