【发布时间】:2022-01-03 07:01:57
【问题描述】:
我已经尝试在堆栈面板中使用 HorizontalAlignment="Stretch" 属性,但也没有这样做。 我现在可以通过提供固定宽度的堆栈面板来做到这一点的唯一方法,但我不希望那样。
如何设置这个树视图模板的背景与整个窗口拉伸?
<HierarchicalDataTemplate DataType="{x:Type local:Data}" ItemsSource="{Binding FamilyTexts}">
<StackPanel Orientation="Horizontal" Background="Green">
<Image x:Name="img" Source="{Binding Default.imageLocation}" ></Image>
<Label Content="{Binding Location}"/>
</StackPanel>
</HierarchicalDataTemplate>
【问题讨论】:
-
您是否尝试使用“TreeView”本身的“ItemContainerStyle”属性设置 TreeViewItem 对象的样式?
-
堆叠面板的工作方式类似于松紧带。它的内容只会与内容一样广泛。