'XAML WrapPanel inside TreeView


I have a TreeView displaying items through a Hierarchical Data Template. Now I want to display two properties of an object in the TreeView, as in:
Object1 Name                 Object1 Src
  Object2 Name               Object2 Src
    Object3 Name             Object3 Src

How can I format the output, so that the Src is always aligned on the right side of the TreeViewItem?



Solution 1:[1]

The TreeViewItem is not streched to full width by default. You can do this by overriding the default style.

<Style TargetType="TreeViewItem" BasedOn="{StaticResource {x:Type TreeViewItem}}">
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kux