I'm trying to display a class using a treeview but nothing is displayed. I've inspected the container with Snoop and I see the StackPanel, but it's empty, even the the project does have a title and pages. There are no binding errors and I have no idea why it's not working.
public class Project : INotifyPropertyChanged {
public string Title {get;set;}
public ObservableCollection<InfoPage> Pages {get;set;}
...
public class InfoPage : INotifyPropertyChanged {
public string Title {get;set;}
public ObservableCollection<InfoPage> Pages {get;set;}
...
<HierarchicalDataTemplate x:Key="ProjectPageTemplate" ItemsSource="{Binding Pages}">
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="ProjectTemplate" ItemsSource="{Binding Pages}">
<StackPanel>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Title}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis"/>
</StackPanel>
<HierarchicalDataTemplate.ItemTemplate>
<HierarchicalDataTemplate>
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis"/>
</HierarchicalDataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
Then on the Window itself:
public static DependencyProperty ProjectProperty = DependencyProperty.Register("Project", typeof(Project), typeof(WinMain));
public Project Project {
get { return base.GetValue(ProjectProperty) as Project; }
set { base.SetValue(ProjectProperty, value); }
}
<TreeView x:Name="trePages" Grid.Row="2" Grid.Column="0" ItemsSource="{Binding Project,ElementName=root,Converter={StaticResource dbg},Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemTemplate="{StaticResource ProjectTemplate}"/>