private static void OnCalendarButtonStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
Style newStyle = e.NewValue as Style;
Style oldStyle = e.OldValue as Style;
Calendar c = d as Calendar;
if (newStyle != null && c != null)
{
CalendarItem monthControl = c.MonthControl;
if (monthControl != null && monthControl.YearView != null)
{
foreach (UIElement child in monthControl.YearView.Children)
{
CalendarButton calendarButton = child as CalendarButton;
if (calendarButton != null)
{
EnsureCalendarButtonStyle(calendarButton, oldStyle, newStyle);
}
}
}
}
}