【问题标题】:How to scroll a Grid?如何滚动网格?
【发布时间】:2013-07-30 13:38:12
【问题描述】:

我有一个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 应用程序。

【问题讨论】:

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


【解决方案1】:

您可以将网格构造为:

 <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>

【讨论】:

  • 是否可以在不看到滚动条的情况下滚动滚动查看器?
  • @ching - 将VerticalScrollBarVisibility 设置为Hidden
  • @keyboardPthanx,我不知道这件事并正在搜索,但感谢 VerticalScrollBarVisibility 隐藏
  • @M.N.S. - 没问题:)
【解决方案2】:

简而言之,尽管您不会滚动网格。您将创建一个设置为屏幕尺寸或更小的网格。然后在里面放一个列表框。您可以轻松滚动列表框,因为它就是这样做的。

<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>

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

【讨论】:

    猜你喜欢
    • 2020-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-28
    • 2015-06-03
    • 1970-01-01
    • 2019-11-08
    • 1970-01-01
    相关资源
    最近更新 更多