I'm presenting a tree structure via a TreeView. As it is unknown how deep the tree will be, I'm using a recursive HierarchicalDataTemplate.
In the following code I'm Databinding to an external Object Tree
public class Tree : ObservableCollection<Node> {}
This works fine:
<TreeView ItemsSource="{Binding Source={StaticResource Tree}}">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type src:Node}" ItemsSource="{Binding Path=Children}">
<TextBlock Text="{Binding Path=Name}" />
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
But when I try to bind to a Property
public ObservableCollection<Node> LocalTree{
get;
set;
}
Changing the first line of the XAML to
<TreeView ItemsSource="{Binding LocalTree}">
The TreeView stays empty. What am I doing horribly wrong?