I do not get the correct Binding syntax to access the Cats
and Dogs
properties of MyViewModel
within a DateTemplate
that defines a CompositeCollection
within its resources.
public class MyViewModel
{
public ObservableCollection<Cat> Cats { get; private set; }
public ObservableCollection<Dog> Dogs { get; private set; }
}
<DataTemplate DataType={x:Type local:MyViewModel}">
<DataTemplate.Resources>
<CompositeCollection x:Key="MyColl">
<!-- How can I reference the Cats and Dogs properties of MyViewModel? -->
<CollectionContainer Collection="{Binding Dogs, ????}">
<CollectionContainer Collection="{Binding Cats, ????}">
</CompositeCollection>
</DataTemplate.Resources>
<ListBox ItemsSource="{StaticResource MyColl}">
<!-- ... -->
</ListBox>
</DataTemplate>
What do I have to insert for ???? to bind the Dogs
and Cats
collections to the CollectionContainer
s?
CollectionContainer
resource the same way and use it directly, instead of indirecting through theCollectionViewSource
? and 2) why can't I declare aCompositeCollection
as a resource and just bind toCollectionContainer
objects within directly? What is so special aboutCollectionViewSource
that it works here even when other types won't? – Knap