Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It works if you don't specify an ItemTemplate in the HierarchicalDataTemplate (left margin added to actually see the tree hierarchy):</p> <pre><code>&lt;Grid&gt; &lt;Grid.Resources&gt; &lt;HierarchicalDataTemplate x:Key="NavGroupTemplate" ItemsSource="{Binding Items}"&gt; &lt;TextBlock Text="{Binding Name}"/&gt; &lt;/HierarchicalDataTemplate&gt; &lt;Style x:Key="RootItemStyle" TargetType="{x:Type TreeViewItem}"&gt; &lt;Setter Property="IsExpanded" Value="True"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="TreeViewItem"&gt; &lt;Grid Margin="16 0 0 0"&gt; &lt;Expander x:Name="Exp" TextElement.FontWeight="Bold" IsExpanded="{TemplateBinding TreeViewItem.IsExpanded}"&gt; &lt;Expander.Header&gt; &lt;ContentPresenter x:Name="ExpCP" ContentSource="Header"/&gt; &lt;/Expander.Header&gt; &lt;ItemsPresenter/&gt; &lt;/Expander&gt; &lt;Border x:Name="CP" Padding="25,0,0,0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Visibility="Collapsed"&gt; &lt;ContentPresenter ContentSource="Header" HorizontalAlignment="Left" VerticalAlignment="Center" /&gt; &lt;/Border&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="HasItems" Value="false"&gt; &lt;Setter TargetName="Exp" Property="Visibility" Value="Collapsed"/&gt; &lt;Setter TargetName="CP" Property="Visibility" Value="Visible" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsSelected" Value="True"&gt; &lt;Setter Property="Background" Value="Red"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Grid.Resources&gt; &lt;TreeView ItemsSource="{Binding}" ItemTemplate="{StaticResource NavGroupTemplate}" ItemContainerStyle="{StaticResource RootItemStyle}"&gt; &lt;/TreeView&gt; &lt;/Grid&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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