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

OnVisibleMonthChanged() private static method

private static OnVisibleMonthChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
d System.Windows.DependencyObject
e System.Windows.DependencyPropertyChangedEventArgs
return void
        private static void OnVisibleMonthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MonthCalendar mcc = (MonthCalendar)d;
            DateTime oldDate = (DateTime)e.OldValue;
            DateTime newDate = (DateTime)e.NewValue;

            //oldDate != newDate in Year/Month field
            if (MonthCalendarHelper.CompareYearMonth(oldDate, newDate) != 0)
            {
                try
                {
                    //raise the event
                    mcc.OnVisibleMonthChanged(new RoutedPropertyChangedEventArgs<DateTime>(oldDate, newDate, VisibleMonthChangedEvent));
                }
                finally
                {
                    mcc.SetFlag(Flags.IsSwitchingMonth, true);
                    try
                    {
                        mcc.InvalidateVisibleDays(MonthCalendarHelper.SubtractByMonth(newDate, oldDate));
                    }
                    finally
                    {
                        mcc.SetFlag(Flags.IsSwitchingMonth, false);
                    }
                }
            }
        }

Same methods

MonthCalendar::OnVisibleMonthChanged ( RoutedPropertyChangedEventArgs e ) : void