我试图使用WrapPanel和方向=“横向”时,拉伸ListBoxItems:水平定向-ListBoxItems不会拉伸
<ListBox HorizontalContentAlignment="Stretch" ItemsSource="{Binding SomeCollection}">
<ListBox.ItemTemplate>
<DataTemplate>
<Border>
<!--Some Textboxes and Labels-->
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
如果我不使用WrapPanel将扩大到ListBoxItems匹配ListBox的大小。当我使用WrapPanel时,ListBoxItems具有最小宽度。
简述:
我有两个ListBoxItems列表水平定向:
当我展开主窗口,列表框也将扩大,因为我的HorizontalAlignment =“拉伸”,但ListBoxItems不会。
所以,我想是像下面的例子中,列表框,扩大ListBoxItems:
难道还有比列表框对于这种情况其他更好的控制? 请让我知道,如果这不够清楚。 感谢您的帮助。
我不能尝试了这一点,看看它是否是一个问题,但尝试添加IsItemsHost =“true”添加到WrapPanel 。 [MSDN文档](http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.isitemshost.aspx) – 2012-07-17 16:53:27
@Wonko the Sane刚刚尝试过,似乎没有任何区别:( – Aris 2012-07-17 16:58:47
也设置你的HorizontalAlignment =“Stretch”为WrapPanel? – 2012-07-17 17:09:34