<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 仅将项目布置在一行中,显示下方的水平滚动条,而所有项目都“隐藏”在右侧,超出了窗口的大小。
我怎样才能防止这种情况?