I want to color some dates in the Calendar control based on a runtime value. Using the style template doesn't quite do it it seems. What I need is programmatic
access to the individual CalendarDayButton controls in the Calendar control. I can get at the CalendarItem in the Calendar using code like this:
public class CalendarEx : Calendar
public override void OnApplyTemplate()
CalendarItem item = this.GetTemplateChild("CalendarItem") as CalendarItem;
item.Background = new SolidColorBrush(Colors.Brown);
This sets the background color of the control to brown. I cannot do the same with the CalendarDayButton as that class, and the CalendarItem class are sealed.
Also, setting the template doesn't give me access to each individual button. Is there a solution to my problem other than rewriting a Calendar control from scratch?