Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you reproduce the text displayed in a TreeViewItem while using a ControlTemplate?
    text
    copied!<p>I am attempting to modify a TreeView to display the TreeViewItem values above and below their child items, such that:</p> <pre><code>foo |bar ||baz |biz </code></pre> <p>would become</p> <pre><code>foo |bar ||baz | baz |bar |biz biz foo </code></pre> <p>A trimmed representation of the current control template is provided below, provided with no guarantee that this snippet compiles:</p> <pre><code>&lt;ControlTemplate TargetType="{x:Type TreeViewItem}"&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition MinWidth="19" Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;ToggleButton x:Name="Expander" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/&gt; &lt;Border Name="Bd" Grid.Column="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"&gt; &lt;ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/&gt; &lt;/Border&gt; &lt;ItemsPresenter x:Name="ItemsHost" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"/&gt; &lt;TextBlock Text="Some Binding Goes Here" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2"/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; </code></pre> <p>The repeated entries would not have children, it would just be the display value. Thus far I can modify the TreeView ContainerStyle using a ControlTemplate to insert a TextBlock at the appropriate place in the visual tree. What data binding should be used in order to fetch the appropriate display value?</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