I have a UserControl with a property of type Dictionary, called HighlightedDates
. The property holds a set of dates, with a tool tip string for each date, and it works fine when set from code.
I want to bind the HighlightedDates
property to a view model property, DatesWithNotes, of the same type, using this markup:
<MyControls:MyCalendar SelectedDate="{Binding SelectedDate}"
HighlightedDates="{Binding DatesWithNotes}" />
Unfortunately, I get this exception when I try to do that:
A 'Binding' cannot be set on the 'Value' property of type 'DictionaryEntry'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
It looks like WPF is trying to bind an individual entry, not the Dictionary itself.
As an alternative, I am looking at having the view model push each new value added to its dictionary out to the user control's dictionary, which seems awfully clumsy. And that brings me to my question: Is there a way to make this binding work? Thanks for your help.