在XAML中使用ScrollViewer会增加Metro App中整页的大小

时间:2015-11-04 10:46:12

标签: windows-phone-8 windows-phone-8.1 windows-store-apps windows-store

我需要一个ScrollViewer来垂直滚动页面,但是当我将VerticalScrollBarVisibility更改为true或者自动增加整个页面的大小时.HorizantalScroll工作正常。

  

这是我迄今为止尝试过的代码:

<Grid x:Name="PivotMain" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="2*"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>

            <Grid x:Name="ContentPanel" Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1293*"/>
                    <ColumnDefinition Width="74*"/>
                </Grid.ColumnDefinitions>
                <Grid.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="Black" Offset="0"/>
                        <GradientStop Color="#FF00D7FF" Offset="1"/>
                    </LinearGradientBrush>
                </Grid.Background>
                <FlipView x:Name="flipviewMain" SelectionChanged="flipviewMain_SelectionChanged" Grid.ColumnSpan="2">
                    <FlipView.ItemTemplate>
                        <DataTemplate>
                            <Image Source="{Binding imagepath}" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Center" Stretch="Uniform"/>
                        </DataTemplate>
                    </FlipView.ItemTemplate>
                </FlipView>
            </Grid>
            <Grid Background="White" Grid.Row="3">
                <StackPanel  Grid.Row="3" x:Name="stackPage" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,30,0,0" />

            </Grid>

            <Grid Background="White" Grid.Row="4">
                <StackPanel Orientation="Horizontal" Grid.Row="4" Background="White" HorizontalAlignment="Center" Height="45" VerticalAlignment="Top">
                    <TextBlock Text="New Games" Foreground="Black" FontSize="30" FontWeight="Bold" Margin="0,0,80,0"/>
                    <TextBlock Text="Premium Games" Foreground="Black" FontSize="30" FontWeight="Bold"  Margin="0,0,80,0"/>
                    <TextBlock Text="Featured Games" Foreground="Black" FontSize="30" FontWeight="Bold"  Margin="0,0,80,0"/>
                </StackPanel>
            </Grid>
            <Grid Background="White" Grid.Row="5">

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <StackPanel  HorizontalAlignment="Left" Height="45" VerticalAlignment="Top" >
                    <TextBlock Text="New Games" Foreground="Black" FontSize="30" FontWeight="Bold" />
                </StackPanel>

            </Grid>
            <ScrollViewer Grid.Row="6" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Visible">
                <Grid Background="White" >
                    <StackPanel Orientation="Horizontal">
                        <Image Source="images/logo1.jpg"/>
                        <Image Source="images/logo2.jpg" Margin="50,0,0,0"/>
                        <Image Source="images/logo3.jpg" Margin="50,0,0,0"/>
                        <Image Source="images/logo4.jpg" Margin="50,0,0,0"/>
                        <Image Source="images/logo1.jpg" Margin="50,0,0,0"/>
                        <Image Source="images/logo2.jpg" Margin="50,0,0,0"/>
                        <Image Source="images/logo3.jpg" Margin="50,0,0,0"/>
                        <Image Source="images/logo4.jpg" Margin="50,0,0,0"/>
                        <Image Source="images/logo1.jpg" Margin="50,0,0,0"/>
                        <Image Source="images/logo2.jpg"/>
                    </StackPanel>
                </Grid>
            </ScrollViewer>
        </Grid>
    </ScrollViewer>
</Grid>

1 个答案:

答案 0 :(得分:0)

您可能需要设置VerticalScrollBarVisibilityVerticalScrollMode,但更重要的是 - 您正在嵌套ScrollViewers并且内部{{1}无限空间,所以它可能会使它变得非常大。否则,您可能需要共享一些屏幕截图。