I'm trying to create a custom list which features a List of objects. Though when this is set both in the Xaml and the code behind I get a "Incorrect markup error". Below is how I'm settings up the PropertyKey and Property.
private static readonly DependencyPropertyKey ItemSourcePropertyKey = DependencyProperty.RegisterReadOnly(
"ItemSource",
typeof(List<object>),
typeof(MultiSelectComboBox),
new FrameworkPropertyMetadata(null));
public static readonly DependencyProperty ItemSourceProperty = ItemSourcePropertyKey.DependencyProperty;
The Field is:
public List<object> ItemSource
{
get { return (List<object>)this.GetValue(ItemSourceProperty); }
set { this.SetValue(ItemSourceProperty, value); }
}
The error I get is:
{"Cannot create instance of 'Window1' defined in assembly 'GroupExpansion, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 1 Position 9."}
Has anyone bound a DependencyProperty to a List before? I've come across a few tutorials but when I try to emulate the tutorials it falls on it's face. The List and Property are in a file which extends a UserControl. If you need any more details just ask. I've been banging my head off the keyboard now for a couple of days. Seem to be going round in circles.
Cheers