我試圖使用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