Calendar background color

Mar 4, 2009 at 7:41 AM
How can I change the background color of specific dates in the calendar?
Mar 4, 2009 at 7:39 PM
There are probably a few ways to go about this, but I think they would all involve creating your own CalendarDayButton style (easiest way to do this is to copy and modify the style from the Calendars generic.xaml).

If you look in the styles template, you'll find:

<Rectangle x:Name="Background" RadiusX="1" RadiusY="1" Opacity="0" Fill="{TemplateBinding Background}"/>

The DataContext of the button is already set to the current DateTime of the day in question, so you could do something like:

Fill="{Binding Path=Date, Converter={StaticResource DateColorFormatter}}"

assuming you had defined a resource as DateColorFormatter pointing to an IValueConverter (Google IValueConverter if you're not familiar with it).

Maybe not the most straight forward of solutions, but it's the first one that came to mind. Be interested if anyone else had a more direct approach

Mar 10, 2009 at 5:24 PM
thank you for your reply.
Would you mind to tell me more about this?
How can I apply the CalendarDayButton style in the WPF?
How can I bind the path with date?