views:

36

answers:

1

I've got an odd problem with a WPF Calendar control. I have modified the control template to display date highlighting, and basically, it works very well. Highlighted dates are specified in a 31-element string array. If an element is null, it means the date that corresponds to that element isn't highlighted. If the string element isn't null, the date is highlighted, and the control can display the string in a tool tip. I have posted the control on CodeProject.com.

Here's my problem: The highlighting doesn't update until the user clicks on a different month. For example, I am using the modified calendar in a logging application. Dates with log entries are highlighted. The user selects a date and makes a log entry in a text box. If the date isn't highlighted, it should highlight when the user submits the log entry. But as it stands now, the highlighting doesn't appear until the user clicks forward or backward a month, then clicks back to the original month.

The usual methods for forcing an update (InvalidateVisual(), InvalidateArrange(), UpdateLayout(), and so on) have no effect. I can work around the problem by setting the calendar to a different month in code when the user submits the log entry, and then immediately setting it to the original month. That has the same effect as the user clicking to a different month, then back again.

But that's obviously a pretty ugly hack, and I am hoping someone who has done something similar with the WPF Calendar can shed some light on what I might do to get the Calendar to completely refresh itself. In other words, why doesn't the highlighting appear immediately, and what do I need to do to fix the problem? Thanks for your help.

A: 

I found my answer. The bug was in my code. My control uses a value converter as a part of the highlighting code, and the problem was located there. I will post an update to the article on CodeProject.com in the next few days.

David Veeneman