ScrollViewer中的网格不会水平滚动

时间:2013-02-10 17:18:03

标签: c# windows-store-apps scrollviewer

我想我在这里缺少一些简单的东西......如何在Grid内部ScrollViewer水平滚动?我启用了HorizontalScrollMode,内容肯定足够长,以至于它在屏幕上运行,但它不会滚动。以下是有问题的代码(此ScrollViewer是LayoutRoot Grid行的唯一内容):

<ScrollViewer Grid.Row="1" VerticalScrollMode="Disabled"
              VerticalScrollBarVisibility="Hidden"
              HorizontalScrollMode="Enabled">
    <Grid Margin="120,0,0,100">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="240"/>
            <ColumnDefinition Width="20"/>
            <ColumnDefinition Width="240"/>
            <ColumnDefinition Width="20"/>
            <ColumnDefinition Width="240"/>
            <ColumnDefinition Width="20"/>
            <ColumnDefinition Width="240"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TextBlock Text="Download" HorizontalAlignment="Center" Margin="0,0,0,10"/>
        <local:BandwidthMeter Grid.Row="1" x:Name="PolicyDown" Grid.Column="0"/>
        <TextBlock Grid.Column="2" Text="Upload" HorizontalAlignment="Center"/>
        <local:BandwidthMeter Grid.Row="1" x:Name="PolicyUp" Grid.Column="2"/>
        <TextBlock Grid.Column="4" Text="Download" HorizontalAlignment="Center"/>
        <local:BandwidthMeter x:Name="ActualDown" Grid.Row="1" Grid.Column="4"/>
        <TextBlock Grid.Column="6" Text="Upload" HorizontalAlignment="Center"/>
        <local:BandwidthMeter x:Name="ActualUp" Grid.Row="1" Grid.Column="6" />
        <TextBlock Grid.Column="7" Text="Campus-wide bandwidth usage" HorizontalAlignment="Center"/>
        <Image Grid.Column="7" Grid.Row="1" Margin="80,0,0,0" Source="[image URL]" Stretch="UniformToFill"/>
    </Grid>
</ScrollViewer>

1 个答案:

答案 0 :(得分:5)

将属性HorizontalScrollBarVisibility="Auto"添加到ScrollViewer