2

我想我在这里遗漏了一些简单的东西......我如何让一个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>
4

1 回答 1

5

将属性添加HorizontalScrollBarVisibility="Auto"到您的ScrollViewer.

于 2013-02-10T17:55:47.823 回答