I am attempting to modify a TreeView to display the TreeViewItem values above and below their child items, such that:
foo
|bar
||baz
|biz
would become
foo
|bar
||baz
| baz
|bar
|biz
biz
foo
A trimmed representation of the current control template is provided below, provided with no guarantee that this snippet compiles:
<ControlTemplate TargetType="{x:Type TreeViewItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="19"
Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ToggleButton x:Name="Expander"
IsChecked="{Binding Path=IsExpanded,
RelativeSource={RelativeSource TemplatedParent}}"
ClickMode="Press"/>
<Border Name="Bd"
Grid.Column="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}">
<ContentPresenter x:Name="PART_Header"
ContentSource="Header"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
</Border>
<ItemsPresenter x:Name="ItemsHost"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="2"/>
<TextBlock Text="Some Binding Goes Here"
Grid.Row="2"
Grid.Column="1"
Grid.ColumnSpan="2"/>
</Grid>
</ControlTemplate>
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?
Why not use a ContentPresenter
again?
<ContentPresenter ContentSource="Header"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Grid.Row="2"
Grid.Column="1"
Grid.ColumnSpan="2"/>