i have a problem with WPF Binding. I want to bind a list of Months to a ItemsControl that shows a Calendar Control for each month. But each rendered Calendar shows DateTime.Now,
The issue appears to be with how the Calendar initializes the DisplayDate property. It currently does it like this:
public Calendar() {
// ...
base.SetCurrentValueInternal(DisplayDateProperty, DateTime.Today);
}
It appears that even though the DisplayDate is being initialized before the binding is established, it will still be pushed back to the binding source as if it were set after. This is most likely a bug.
You can work around it using something like:
public class MyCalendar : Calendar {
public MyCalendar() {
this.ClearValue(DisplayDateProperty);
}
}
Or you could establish the binding at a later time (i.e. when the Calendar is loaded) using an event handler or attached behavior.