HierarchicalDataTemplate is already a DataTemplate (it is obtained from it). So just skip the ItemTemplate and DataTemplate elements inside your HierarchicalDataTemplate as follows:
<TreeView Name="treeView" Margin="5">
<TreeView.Resources>
<HierarchicalDataTemplate ItemsSource="{Binding Path=Folders}" DataType="{x:Type WpfApplication220:Folder}">
<TextBlock Text="{Binding Path=Name}"></TextBlock>
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
Oh, and you have to set the ItemSource of your tree image programmatically or in your markup.
treeView.ItemsSource = ..yourFolderList..
Sveng source
share