开发者

Increase the spacing between TreeViewItems in a TreeView

开发者 https://www.devze.com 2022-12-25 10:14 出处:网络
Im working with a TreeView in WPF. What I have is :- TreeRoot -TreeViewItem1 -TreeViewItem2 -TreeViewItem3

Im working with a TreeView in WPF. What I have is :-

TreeRoot -TreeViewItem1 -TreeViewItem2 -TreeViewItem3 -TreeViewItem4

What I w开发者_StackOverflowant is

TreeRoot -TreeViewItem1

-TreeViewItem2

-TreeViewItem3

-TreeViewItem4

So, Is there a way to increase the spacing between the TreeViewItems


If I understand the question correctly, you can modify the vertical spacing through the ItemContainerStyle property on the TreeView:

<Window.Resources>
    <Style x:Key="TreeViewItemStyle" TargetType="TreeViewItem">
        <Setter Property="Margin" Value="5 20 5 5" />
    </Style>
</Window.Resources>

<Grid>
    <TreeView ItemContainerStyle="{StaticResource TreeViewItemStyle}">
        <TreeViewItem Header="One" />
        <TreeViewItem Header="Two" />
        <TreeViewItem Header="Three" />
    </TreeView>
</Grid>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号