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;
}