0

我的 StackPanel 和 ScrollViewer 似乎并没有在 Grid.Row 位置结束。我正在制作一个 Metro 应用程序,因此网格以及所有元素都必须是动态的。

编码:

<Grid Background="#FFE4E4E4">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.5*"/>
            <ColumnDefinition Width="0.5*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.5*"/>
            <RowDefinition Height="0.5*"/>
        </Grid.RowDefinitions>

        <!--News/Leaderboard Feed-->
        <StackPanel Grid.Column="0" Grid.Row="0">

        </StackPanel>

        <!--Marketplace Feed-->
        <StackPanel Grid.Column="0" Grid.Row="1">

        </StackPanel>

        <!--Detailed Marketplace Account-->
        <StackPanel Grid.Column="1" Grid.Row="1">

        </StackPanel>


        <!--Marketplace View-->
        <StackPanel Grid.Column="1" Grid.Row="0" VerticalAlignment="Top">
            <ScrollViewer VerticalAlignment="Top">
                <!--Allows scrolling-->

                <GridView x:Name="MarketplaceFeed" ItemsSource="{Binding StockList}" ItemTemplate="{StaticResource MarketplaceFeedTemplate}" VerticalAlignment="Top">
                    <!--Displays the stock markets the user is interested in.-->
                    <GridView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapGrid Orientation="Horizontal" />
                        </ItemsPanelTemplate>
                    </GridView.ItemsPanel>
                </GridView>


            </ScrollViewer>
        </StackPanel>

    </Grid>
4

1 回答 1

1

您应该将ScrollViewer放在外面。这将自动适应网格,并且其中的任何内容都将得到滚动处理。

   <!--Marketplace View-->
    <ScrollViewer VerticalAlignment="Top" Grid.Column="1" Grid.Row="0">
        <StackPanel VerticalAlignment="Top">
            <!-- other content -->
        </StackPanel>
    </ScrollViewer>
于 2012-08-20T21:40:43.650 回答