I have a WPF TreeView and I want to stretch the TreeViewItem to the entire space like its parent.
<TreeView Name="treeFamilies" AllowDrop="True" >
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type local:MyNode}" ItemsSource="{Binding Members}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" Background="LightGray"/>
<TextBlock Text=" [" Foreground="Blue" Background="LightGray"/>
<TextBlock Text="{Binding Members.Count}" Foreground="Blue" Background="LightGray"/>
<TextBlock Text="]" Foreground="Blue" Background="LightGray" />
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.Resources>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
It seems I'm using the ItemContainer style <Setter Property="HorizontalContentAlignment" Value="Stretch"/> wrongly. My current tree is looking like this picture:
I want tho strech the gray background to fill the entire end of the treeview control. How could I achieve this?
