Highlight particular recurring days or dates

Nov 16, 2012 at 12:43 PM

I need if possible to highlight Saturdays and Sundays as they scroll across the timeline. (Or it could be say, every 1st January, or every birth date or any such recurring events)

I guess I could do it by generating a specific event-format template which fills the entire column and then generate events for every week-end (or whatever recurring event) ... but can anyone advise as to whether it might be neater for me to customise the control for my own use only to achieve this, and if so point me to the area of code I should look at?

(I'm assuming that there is no "pre-defined" way of doing this?!)



Jan 3, 2013 at 11:02 AM

In case anyone else is interested, this turned out to be relatively easy to achieve, for weekends at least, if slightly "clunky" and specific to my own requirements. I'm sure it could be improved upon.

First step was to modify ItemToString in TimelineCalendar to prefix returned string with "Sat" or "Sun" if GetDayOfWeek(d) returned DayOfWeek.Saturday or DayOfWeek.Sunday, for "Days" and "Hours" bands. So now in my timeline bands the days are displayed as "01", "02", "Sat 03", "Sun 04", "05" and so on, and if the days are Saturday or Sunday, then the hours (in Hours bands) are displayed as "Sat 10:00", "Sat 11:00" etc, while weekdays display as "10:00", "11:00" etc.

Next I created an IValueConverter which simply does

Return If(Left(UCase(value.ToString), 1) = "S""WhiteSmoke""Transparent")

(I'm doing all this in VB as opposed to C# by the way, but the principle remains the same of course)

I then surrounded the TextBlock in the ColumnTemplateStyle with a Border (which conveniently auto-expands to fill the entire column), whose background is derived from the IValueConverter. The relevant section of the template now looks like

                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                    <GradientStop Color="#FF575956" Offset="0"/>
                        <GradientStop Color="{Binding Converter={StaticResource WeekendToColourConverter}}" Offset="0.01"/>
                        <GradientStop Color="{Binding Converter={StaticResource WeekendToColourConverter}}" Offset="0.99"/>
                    <GradientStop Color="#FF828282" Offset="1" />
                <TextBlock FontFamily="Trebuchet MS" TextWrapping="Wrap" FontSize="10" Margin="3,0,2,2" FontWeight="Bold" 
                           FontStyle="Italic" VerticalAlignment="Bottom" Text="{Binding}" Foreground="Black">
                        <DropShadowEffect Color="White" BlurRadius="2" Direction="274" ShadowDepth="1" />

And that does it!