如何滚动网格?

时间:2013-07-30 12:01:41

标签: c# windows-phone-7 xaml windows-phone-8

我有一个Grid Height可以像这样成长:

<Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>


<Grid Name="Grid" Grid.Row="0" Grid.Column="0">

</Grid>

如何向上滚动?

它是一款Windows Phone 8应用程序。

2 个答案:

答案 0 :(得分:7)

您可以将网格结构化为:

 <Grid x:Name="LayoutRoot" Background="Transparent">
       <Grid.RowDefinitions>
    <RowDefinition Height="120" />
    <RowDefinition Height="*" />
    <RowDefinition Height="3*" />
    <RowDefinition Height="5*" />
</Grid.RowDefinitions>
        <Grid> 
           ***content goes here****
        </Grid>
        <ScrollViewer VerticalScrollBarVisibility="Visible" Grid.Row="1">
            *****Put scalable content here*******
        </ScrollViewer>
        <Grid Grid.Row="0"> 
           ***content goes here****
        </Grid>
    </Grid>

答案 1 :(得分:1)

简而言之,你不打算滚动网格。您将创建一个设置为屏幕尺寸或更小的网格。然后在其中放入一个列表框。您可以轻松滚动列表框,因为它就是它的作用。

<Grid margin="0,0,0,0" width="480" hieght="800"> <!--These values probably need ajusted-->
  <ListBox height="800"> <!--Make sure that it is ENTIRLEY on the screen -->
    <TextBlock>Put a ton of text here and see that it scrolls</TextBlock>
    <Button>You can put anything in the list boxes</Button>
    <TextBox>Even Inputs</TextBox>
  </ListBox>
</Grid>

下面提到的另一个可行选项是滚动查看器,它也可以正常工作。