0
相对结合我有一个包含一个ObservableCollection一个ObservableCollection:WPF使用分层集合结构
public class BooksDetailModel
{
public BookModel Book{ get; set; }
public ObservableCollection<AuthorModel> Authors { get; set; }
}
属性,视图模型:
public ObservableCollection<BooksDetailModel> Books { get; set; }
我想使这个在这样的列表框:
Book1
- 作者1
- Author2
第二册
- 作者1
等
顶级绑定是容易的,但我有与内子集的麻烦。
XAML至今:
<ListBox ItemsSource="{Binding Books}" BorderBrush="{x:Null}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Book.Name}" FontSize="12" FontWeight="Bold" />
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ???, Path=Author.Name}" FontSize="10" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
的任何建议??? - 将内部列表框项目源相对绑定到父项目源的作者集合。
你应该使用HierarchicalDataTemplate – 2011-03-07 17:16:43