杰夫·威尔科克斯的评论让我思考,我发现自己做错了什么。我当时正在修改文件
ItemsPanel
TreeView
,但为了实现我想要的,我必须修改
的
TreeViewItem
:
<controls:TreeView>
<controls:TreeView.ItemContainerStyle>
<Style TargetType="controls:TreeViewItem">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
</controls:TreeView.ItemContainerStyle>
<controls:TreeViewItem Header="Root" IsExpanded="True">
<controls:TreeViewItem Header="Alfa"/>
<controls:TreeViewItem Header="Beta"/>
<controls:TreeViewItem Header="Gamma"/>
</controls:TreeViewItem>
</controls:TreeView>