我没有得到正确的 Binding 语法来访问在其资源中定义 a 的a的Cats
和Dogs
属性。MyViewModel
DateTemplate
CompositeCollection
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>
我必须插入什么????将Dogs
andCats
集合绑定到CollectionContainer
s?