I am trying to make a WPF Application containing a treeview, whose data will be populated from the database. Since I am new to all this, I tried using the simple tutorial that can be found at http://dev102.blogspot.com/2007/12/how-to-use-hierarchical-datatemplate-in.html
I tried following the steps exactly, but all I am getting is just the root node. My xaml looks like this:
<Window x:Class="Hierarchical_attempt.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:data="clr-namespace:Hierarchical_attempt"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<HierarchicalDataTemplate DataType="{x:Type data:Root}"
ItemsSource="{Binding Path=WebPages}">
<TextBlock Text="{Binding Title}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type data:WebPage}"
ItemsSource="{Binding Path=LinksInPage}">
<TextBlock Text="{Binding PageTitle}" />
</HierarchicalDataTemplate>
</Window.Resources>
<Grid>
<TreeView Name="tree1">
<TreeViewItem ItemsSource="{Binding Path=Webpages}"
Header="{Binding Title}">
</TreeViewItem>
</TreeView>
</Grid>
</Window>
Can you plese tell me where am I going wrong? I am just tring this since this will give me a heads up as to how to go about the treeview. However, what I actually have to do is to populate the data fom the database in the treeview. If you know of any step by step tutorial available, then that will also be really helpful. Thanks. Please reply soon.