Пример #1
0
        private static object CoerceDate(DependencyObject d, object value)
        {
            DateTimePickerView me      = (DateTimePickerView)d;
            DateTime           current = Convert.ToDateTime(value);

            if (current < me.MinimumDate)
            {
                current = me.MinimumDate;
            }
            if (current > me.MaximumDate)
            {
                current = me.MaximumDate;
            }
            return(current);
        }
Пример #2
0
        private static object CoerceMaxDate(DependencyObject d, object value)
        {
            DateTimePickerView me      = (DateTimePickerView)d;
            DateTime           current = Convert.ToDateTime(value);

            if (current <= me.MinimumDate)
            {
                throw new ArgumentException("MaximimumDate can not be equal to, or less than MinimumDate");
            }

            if (current < me.SelectedDate)
            {
                me.SelectedDate = current;
            }

            return(current);
        }