我有一些我想弄清楚的代码。我有一个带有5个Grid列的主窗口。我将Stack面板分配给每个网格列。我在每个堆栈面板中放置一个视图声明。问题是视图中的用户控件溢出并且不受主窗口中设置的边界的影响。这是一些代码。
Main.xaml:
<Grid Name="mainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Grid.Row="1">
<view:ViewContent></view:ViewContent>
</StackPanel>
<GridSplitter Grid.Row="1" Grid.Column="0" Panel.ZIndex="3" ResizeDirection="Columns" ShowsPreview="True" Width="3">
</GridSplitter>
</Grid>
ViewContent.xaml:
<UserControl>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Label Grid.Row="0" />
<Label Grid.Row="1" />
<ScrollViewer Grid.Row="2">
<ListView Grid.Row="2" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
//Lots of data goes here and won't work with the scroller.
</ListView>
</ScrollViewer>
</UserControl>
列表视图不会滚动。我希望滚动条仅附加到列表视图。还有一些Grid Splitters附加到列,以便它们可以在主窗口中水平调整大小。