private static void OnCalendarDayButtonStyleChanged(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.MonthView != null)
{
foreach (UIElement child in monthControl.MonthView.Children)
{
CalendarDayButton dayButton = child as CalendarDayButton;
if (dayButton != null)
{
EnsureDayButtonStyle(dayButton, oldStyle, newStyle);
}
}
}
}
}