Note that there are some explanatory texts on larger screens.

plurals
  1. POComplex Silverlight TreeView, is nested hierarchy possible?
    text
    copied!<p>I have a DB that looks like:</p> <pre><code>Locations [rootlevel] Inspections [level1] Areas [level1] Inspections [level2] </code></pre> <p>So each Location can have zero or more Inspections and zero or more Areas, and Areas have zero or more Inspections. The records for Inspections all have a LocationID!=null and the AreaID=null or !=null to get this hierarchy.</p> <p>I would like to get all the names of each item in the table in a treeview as navigation. So far I can get EITHER</p> <p>Locations-->Areas-->Inspections OR</p> <p>Locations-->Inspections</p> <p>I cannot seem to get the treeview hierarchy to show what I need. Is it possible? I have tried to use a nested treeview as an item in the hierarchy to show what I want but it doesn't work correctly.</p> <p>xaml code for Locations-->Areas-->Inspections</p> <pre><code> &lt;!--NAVIGATION TREE HIERARCHICAL TEMPLATE--&gt; &lt;common:HierarchicalDataTemplate x:Key="AssetManager" ItemsSource="{Binding Path=Areas}"&gt; &lt;!--START OF AREA OPTIONS TEMPLATE--&gt; &lt;common:HierarchicalDataTemplate.ItemTemplate&gt; &lt;common:HierarchicalDataTemplate ItemsSource="{Binding Path=Inspections}"&gt; &lt;!--START OF INSPECTION OPTIONS TEMPLATE--&gt; &lt;common:HierarchicalDataTemplate.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Source="Assets/Resources/ImageResources/SearchICON2.png" Height="20" Width="20" /&gt; &lt;TextBlock Margin="0,0,0,0" Text="{Binding Path=Name}"/&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/common:HierarchicalDataTemplate.ItemTemplate&gt; &lt;!--END OF INSPECTION OPTIONS TEMPLATE--&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Source="Assets/Resources/ImageResources/ManufacturingICON.png" Width="20" Height="20"/&gt; &lt;TextBlock Margin="0,0,0,0" Text="{Binding Path=Name}"/&gt; &lt;/StackPanel&gt; &lt;/common:HierarchicalDataTemplate&gt; &lt;/common:HierarchicalDataTemplate.ItemTemplate&gt; &lt;!--END OF AREA OPTIONS TEMPLATE--&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Source="Assets/Resources/ImageResources/ManufacturingICON.png" Width="20" Height="20"/&gt; &lt;TextBlock Margin="0,0,0,0" Text="{Binding Path=Name}"/&gt; &lt;/StackPanel&gt; &lt;/common:HierarchicalDataTemplate&gt; &lt;!--END OF NAVIGATION TEMPLATE--&gt; </code></pre> <p>xaml for Locations-->Inspections</p> <pre><code> &lt;!--NAVIGATION TREE HIERARCHICAL TEMPLATE--&gt; &lt;common:HierarchicalDataTemplate x:Key="AssetManager" ItemsSource="{Binding Path=Inspections}"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Source="Assets/Resources/ImageResources/ManufacturingICON.png" Width="20" Height="20"/&gt; &lt;TextBlock Margin="0,0,0,0" Text="{Binding Path=Name}"/&gt; &lt;/StackPanel&gt; &lt;/common:HierarchicalDataTemplate&gt; &lt;/common:HierarchicalDataTemplate.ItemTemplate&gt; &lt;!--END OF TEMPLATE--&gt; </code></pre> <p>xaml for nested treeview</p> <pre><code> &lt;!--NAVIGATION TREE HIERARCHICAL TEMPLATE--&gt; &lt;common:HierarchicalDataTemplate x:Key="AssetManager" ItemsSource="{Binding Path=Areas}"&gt; &lt;!--START OF AREA OPTIONS TEMPLATE--&gt; &lt;common:HierarchicalDataTemplate.ItemTemplate&gt; &lt;common:HierarchicalDataTemplate ItemsSource="{Binding Path=Inspections}"&gt; &lt;!--START OF INSPECTION OPTIONS TEMPLATE--&gt; &lt;common:HierarchicalDataTemplate.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Source="Assets/Resources/ImageResources/SearchICON2.png" Height="20" Width="20" /&gt; &lt;TextBlock Margin="0,0,0,0" Text="{Binding Path=Name}"/&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/common:HierarchicalDataTemplate.ItemTemplate&gt; &lt;!--END OF INSPECTION OPTIONS TEMPLATE--&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Source="Assets/Resources/ImageResources/ManufacturingICON.png" Width="20" Height="20"/&gt; &lt;TextBlock Margin="0,0,0,0" Text="{Binding Path=Name}"/&gt; &lt;/StackPanel&gt; &lt;/common:HierarchicalDataTemplate&gt; &lt;/common:HierarchicalDataTemplate.ItemTemplate&gt; &lt;!--END OF AREA OPTIONS TEMPLATE--&gt; &lt;StackPanel Orientation="Vertical"&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;Image Source="Assets/Resources/ImageResources/ManufacturingICON.png" Width="20" Height="20"/&gt; &lt;TextBlock Margin="0,0,0,0" Text="{Binding Path=Name}"/&gt; &lt;/StackPanel&gt; &lt;sdk:TreeView HorizontalAlignment="Left" ItemsSource="{Binding Source={StaticResource locationInspectionsViewSource}}" Name="inspectionsTreeView" VerticalAlignment="Top" ItemTemplate="{StaticResource Level2}" BorderBrush="{x:Null}" Background="{x:Null}"/&gt; &lt;/StackPanel&gt; &lt;/common:HierarchicalDataTemplate&gt; &lt;!--END OF NAVIGATION TEMPLATE--&gt; </code></pre> <p>Thank you</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload