I am trying to map a TreeView to a collection using the HierarchicalDataTemplate. The collection contains an Object that contains child entities of itself(Many To Many Relation), and then goes down to another object using regular one to many relation. I use the followings:
<HierarchicalDataTemplate DataType="{x:Type src:Organization}" ItemsSource="{Binding Path=ChildOrgs}" >
<StackPanel>
<TextBlock Text="{Binding Path=Name}"/>
</StackPanel>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type src:Organization}" ItemsSource="{Binding Path=Units}" >
<StackPanel>
<TextBlock Text="{Binding Path=Name}"/>
</StackPanel>
</HierarchicalDataTemplate>
I am using the 'ChildOrgs' collection to retrieve 'Organzation' childs from an Organization. This works perfectly. My problem is that i want the treeview to keep drilling in to the Organizations 'Unit' collection. But i get the following error: "Item has already been added..." on the 'Organization' entity...
Will appriciate any ideas, Many Thanks,