Microsoft.Samples.KMoore.WPFSamples.DateControls.MonthCalendar.CoerceVisibleMonth C# (CSharp) Method

CoerceVisibleMonth() private static method

private static CoerceVisibleMonth ( DependencyObject d, object value ) : object
d System.Windows.DependencyObject
value object
return object
        private static object CoerceVisibleMonth(DependencyObject d, object value)
        {
            MonthCalendar mcc = (MonthCalendar)d;
            DateTime newValue = (DateTime)value;

            DateTime min = mcc.MinDate;
            if (newValue < min)
            {
                return min;
            }

            DateTime max = mcc.MaxDate;
            if (newValue > max)
            {
                return max;
            }

            return newValue;
        }