I have a usercontrol done by myself that has a dependency property that is a collection:
private static readonly DependencyPropertyKey VerticalLinesPropertyKey = DependencyProperty.RegisterReadOnly("VerticalLines", typeof(VerticalLineCollection), typeof(DailyChart), new FrameworkPropertyMetadata(new VerticalLineCollection()));
public static DependencyProperty VerticalLinesProperty = VerticalLinesPropertyKey.DependencyProperty;
public VerticalLineCollection VerticalLines
{
get
{
return (VerticalLineCollection)base.GetValue(VerticalLinesProperty);
}
set
{
base.SetValue(VerticalLinesProperty, value);
}
}
I was filling this collection from XAML directly when a Window was using the control with code like:
<chart:DailyChart.VerticalLines>
<VerticalLine ... ... ... />
</chart:DailyChart.VerticalLines>
Now, I removed this fixed initialization from XAML and I want to bind the collection to a property of the ViewModel but I get the error:
Error 1 'VerticalLines' property cannot be data-bound.
Parameter name: dp
Any ideas?