WPF MvvM堆栈面板和网格溢出

WPF MvvM堆栈面板和网格溢出,wpf,wpf-controls,mvvm-light,scrollviewer,stackpanel,Wpf,Wpf Controls,Mvvm Light,Scrollviewer,Stackpanel,我有一些代码我想弄清楚。我有一个带有5个网格列的主窗口。我将堆栈面板指定给每个网格列。我在每个堆栈面板中放置一个视图声明。问题是视图中的用户控件溢出,并且不受主窗口中设置的边界的影响。下面是一些代码 Main.xaml: <Grid Name="mainGrid"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height

我有一些代码我想弄清楚。我有一个带有5个网格列的主窗口。我将堆栈面板指定给每个网格列。我在每个堆栈面板中放置一个视图声明。问题是视图中的用户控件溢出,并且不受主窗口中设置的边界的影响。下面是一些代码

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>

列表视图不会滚动。我希望滚动条只附加到列表视图。柱上还有网格拆分器,可以在主窗口中水平调整大小。

卸下StackPanel。我将它们全部切换到DockPanel,效果非常好。谢谢!我建议你删除这个问题。这不太可能在将来帮助别人。