<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<c:SearchTextBox Grid.ColumnSpan="2" .../>
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1">
<ListBox
ItemsSource="{Binding Categories}"
IsSynchronizedWithCurrentItem="True"
... />
</ScrollViewer>
<!-- Here is what I'm talking about:-->
<ListBox ItemsSource="{Binding Products}"
IsSynchronizedWithCurrentItem="True" Grid.Column="1" Grid.Row="1">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
我想要的是應該佈置右列中的項目以填充窗口寬度,然後創建一個新行,這正是WrapPanel的作用。
問題是,WrapPanel僅在一行中列出項目,顯示下方的水平滾動條,而所有項目在右側「隱藏」,超出窗口大小。WrapPanel在一條長水平線(顯示滾動條)中列出項目而不是包裝線
我該如何預防?
如果您刪除了scrollviewer,會發生什麼情況?該項目仍然向右擴展到水平滾動? – dcarneiro
@Daniel你讓我錯了。 ScrollViewer包裝第一個ListBox,其中有兩個ListBox代表主 - 細節場景。問題在於使用WrapPanel作爲其ItemsPanelTemplate的第二個ListBox。 – Shimmy