コード例 #1
0
        private static object CoerceValue(DependencyObject d, object baseValue)
        {
            int newValue = (int)baseValue;
            MyDependencyObject control = (MyDependencyObject)d;

            newValue = Math.Max(control.Minimum, Math.Min(control.Maximum, newValue));
            return(newValue);
        }
コード例 #2
0
        private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            //int oldValue = (int)e.OldValue;
            //int newValue = (int)e.NewValue;
            ////...

            MyDependencyObject control = (MyDependencyObject)d;
            var e1 = new RoutedPropertyChangedEventArgs <int>((int)e.OldValue,
                                                              (int)e.NewValue, ValueChangedEvent);

            control.OnValueChanged(e1);
        }