How to embed a listview in to each nodes of the Treeview? I am new to the WPF.
Most often, you bind an ObservableCollection to the ItemSource of the TreeView. The class you bind to should incorporate two things, at least: Children (which is an ObservableCollection of the same class, to form a hierarchy and ListItems, which holds the items you wish to display under each node.
Define the following HierarchicalDataTemplate in Window.Resources (or UserControl.Resources, depending on where you work):
<HierarchicalDataTemplate x:Key="TreeTemplate" ItemsSource="{Binding Path=Children}"
IsExpanded>
<ListView ItemsSource="{Binding Path=ListItems}"/> // or ListBox, which is probably more fitting
</HierarchicalDataTemplate>
And the TreeView:
<TreeView ItemsSource="{Binding Path=Your_Node_List_Here}" ItemTemplate="{StaticResource TreeTemplate}"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.