I tried the linked solution above but it only displays two levels in the TreeView. This answer is pretty close but not quite what I am looking for. The ItemsSource property is not a list it merely implements IEnumerable, therefore Add (), and Remove () are not present. I looked up some other solutiones but could not find any help for my problem. If you are binding to ItemsSource, so remove it from that list. Here is the code I am using to create the tree view. When you right click any of the child nodes (not parents), I would like a simple context menu to display. The following code produces a TreeView as seen below. Instead, we use the HierarchicalDataTemplate, which allows us to template both the tree node itself, while controlling which property to use as a source for child items of the node. I want to bind multiple, different lists to a TreeView in WPF. Create WPF context menu for a TreeView using HierarchicalDataTemplates. Say if I specify 'L', the tree will be filtered and show only RootNode->Leaf and SecondRoot->flowers (because they both contain the letter L). In the example below, we have a TreeView whose ItemsSource is bound to a list of breeds.
![wpf treeview hierarchicaldatatemplate example wpf treeview hierarchicaldatatemplate example](https://www.binarymission.co.uk/wp-content/uploads/2020/07/TreeList_feature-1.png)
The DataControlBase.ItemsSource property contains only data items that correspond to root nodes. Parents and children can be of different object types.
![wpf treeview hierarchicaldatatemplate example wpf treeview hierarchicaldatatemplate example](https://nishantrana.files.wordpress.com/2012/03/031012_2027_usinghierar1.png)
As WPF Tutorial says in their website post TreeView, data binding and multiple templates “The WPF TreeView supports data binding, as pretty much all other WPF controls do, but because the TreeView is hierarchical in nature, a normal DataTemplate often won’t suffice. I have a hypothetical tree view that contains this data: RootNode Leaf vein SecondRoot seeds flowers I am trying to filter the nodes in order to show only the nodes that contain a certain text. A hierarchical data structure is a set of nested objects with a field that contains child records.