I have a class CollectionOfThings. As its name suggests its a simple collection of instances of the Thing class. Thing class has a public default constructor and two simple public get, set properties ID and DisplayName, both are string. CollectionOfThing also has public default constructor.
In XAML I would like to use markup like this:-
<Grid.Resources>
<local:CollectionOfThings x:Key="Things">
<local:Thing ID="1" DisplayName="Hello" />
<local:Thing ID="2" DisplayName="World" />
<local:CollectionOfThings>
</Grid.Resources>
All is good as long as CollectionOfThings derives from a Collection type. However I want CollectionOfThings to also be a DependencyObject. I thought that's fine creating an implementation of ICollection<T>, INotifyCollectionChanged etc is not that hard. Then I can derive from DependencyObject.
Unfortunately ICollection<T> doesn't cut it for some reason. With ICollection<Thing> I get 'CollectionOfThings does not support Thing as content'. Go back to Collection<Thing> and everything works but leaves me without a DependencyObject implementation.
Suggestions anyone?