I am creating a user control to display a three-month calendar. The control is based on the WPF Calendar control (WPF Toolkit 2009-06), and I want to pass several of the Calendar's properties through to corresponding properties of my user control. The user control properties are set up as Dependency Properties, and their underlying types match the types of the Calendar properties. Here is my markup:
<StackPanel>
<toolkit:Calendar Name="MasterCalendar"
SelectionMode="{Binding Path=SelectionMode, Mode=OneWay}"
SelectedDate="{Binding Path=SelectedDate, Mode=OneWayToSource}"
SelectedDates="{Binding Path=SelectedDates, Mode=OneWayToSource}"/>
<toolkit:Calendar Name="SlaveCalendar1"
DisplayDate="{Binding DisplayDate, Converter={StaticResource IncrementalMonthConverter}, ElementName=MasterCalendar, Mode=OneWay}"
SelectionMode="{Binding Path=SelectionMode, Mode=OneWay}"
SelectedDate="{Binding Path=SelectedDate, Mode=OneWayToSource}"
SelectedDates="{Binding Path=SelectedDates, Mode=OneWayToSource}"/>
<toolkit:Calendar Name="SlaveCalendar2"
DisplayDate="{Binding DisplayDate, Converter={StaticResource IncrementalMonthConverter}, ElementName=SlaveCalendar1, Mode=OneWay}"
SelectionMode="{Binding Path=SelectionMode, Mode=OneWay}"
SelectedDate="{Binding Path=SelectedDate, Mode=OneWayToSource}"
SelectedDates="{Binding Path=SelectedDates, Mode=OneWayToSource}"/>
</StackPanel>
All of the properties bind without problem, except for the SelectedDates
property. I get the following error on its binding:
'SelectedDates' property is read-only and cannot be set from markup.
I suspect that it is because the SelectedDates
property is a collection, but I am not sure how to fix the problem. Can anyone enlighten me on the cause of the problem and suggest a fix? Thanks for your help.