コレクションである依存関係プロパティを持つユーザーコントロールを自分で作成しました。
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);
}
}
Window が次のようなコードでコントロールを使用していたときに、このコレクションを XAML から直接入力していました。
<chart:DailyChart.VerticalLines>
<VerticalLine ... ... ... />
</chart:DailyChart.VerticalLines>
ここで、この固定された初期化を XAML から削除し、コレクションを ViewModel のプロパティにバインドしたいのですが、次のエラーが発生します。
Error 1 'VerticalLines' property cannot be data-bound.
Parameter name: dp
何か案は?