CompositeCollection + CollectionContainer: Bind CollectionContainer.Collection to property of ViewModel that is used as DataTemplates DataType
Due to the issue with data binding on CollectionContainer as described http://social.msdn.microsoft.com/Forums/vstudio/en-US/b15cbd9d-95aa-47c6-8068-7ae9f7dca88a/collectioncontainer-does-not-support-relativesource?forum=wpf I now use the following approach: <ListBox> <ListBox.Resources> <CollectionViewSource x:Key=”DogCollection” Source=”{Binding Dogs}”/> <CollectionViewSource x:Key=”CatCollection” Source=”{Binding Cats}”/> </ListBox.Resources> <ListBox.ItemsSource> <CompositeCollection> <CollectionContainer Collection=”{Binding Source={StaticResource DogCollection}}”/> <CollectionContainer Collection=”{Binding Source={StaticResource CatCollection}}”/> </CompositeCollection> </ListBox.ItemsSource> <!– … –> </ListBox> Edit: The CompositeCollection class does not derive from FrameworkElement and … Read more