Custom Day Button Style

Feb 28, 2009 at 8:49 PM
I have set the CalendarDayButtonStyle to my own style, where I inject a user control into to a CalendarDayButton. My user control contains a DateTime property called DisplayDate. I need to bind my user control to the date being dispalyed in the current CalendarDayButton.

Since the CalendarDayButton class does not actually contain a DateTime of the date being rendered, I don't see how this is possible. Any thoughts?
Feb 28, 2009 at 10:24 PM
After digging around in the Toolkit source code (CalendarItem.cs to be exact) I found that the DataContext for each CalendarDayButton was in fact set to the corresponding DateTime. I can therefore bind my user controls DisplayDate property directly to the Date path.

<my:UserControlTest DisplayDate="{Binding Path=Date}" />

Works like a charm! :-)