【问题标题】:WP8 ListBox not scrollingWP8 ListBox 不滚动
【发布时间】:2014-01-23 16:40:14
【问题描述】:

我正在开发一个 WP8 应用程序,但我遇到了滚动问题。在我的页面中,我有一个网格和两个列表框。 你认为为什么? 我也尝试使用 ScrollViewer,但效果很好。

<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">

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

    <TextBlock Name="txt" TextAlignment="Center" 
               FontWeight="Bold"
               FontSize="36" Height="auto" Grid.ColumnSpan="2" Grid.Row="0"></TextBlock>

    <ListBox Name="lstCasa" Grid.Column="0" Grid.Row="1">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Vertical">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                    </Grid>
                    <TextBlock FontWeight="Bold" Text="{Binding Path=aaa}"/>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
    <ListBox Name="lstFuori" Grid.Column="1" Grid.Row="1">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Vertical">
                    <TextBlock FontWeight="Bold" Text="{Binding Path=bbb}"/>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</Grid>

【问题讨论】:

    标签: c# xaml windows-phone-8


    【解决方案1】:

    您的RowDefinition 上的Height="Auto" 没有提供任何调用ScrollViewer 的内容

    它需要一个边界来告诉它“嘿,你已经到了可以显示的地方的尽头,再往前走,就需要滚动了。”

    有意义吗?

    要修复它,您可以将 RowDefinition 设置为“*”或该 Row 或 ListBox(s) 上的固定高度或等同于建立边界点的东西。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-13
      • 1970-01-01
      • 1970-01-01
      • 2014-07-27
      • 1970-01-01
      • 2013-02-24
      • 1970-01-01
      • 2021-05-12
      相关资源
      最近更新 更多