简体   繁体   English

WP8 ListBox不滚动

[英]WP8 ListBox not scrolling

I'm developing a WP8 app and I have scroll problems. 我正在开发一个WP8应用程序,我有滚动问题。 In my page I have a grid and two listbox. 在我的页面中,我有一个网格和两个列表框。 Why in your opinion? 为什么在你看来? I tried also using ScrollViewer but good results. 我也试过使用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>

Height="Auto" on your RowDefinition doesn't give anything to invoke the ScrollViewer RowDefinition上的Height="Auto"没有提供调用ScrollViewer任何内容

It needs a boundary to tell it "Hey you reached the end of where you're allowed to display, any further and it's going to require scrolling." 它需要一个边界来告诉它“嘿,你到达了允许显示的地方的末端,任何进一步的,它将需要滚动。”

Make sense? 说得通?

To fix it, you could put your RowDefinition to "*" or a fixed height on either that Row or the ListBox(s) or something equivalent to establish a boundary point. 要修复它,您可以将RowDefinition设置为“*”或固定高度,或者放在Row或ListBox上,或等效于建立边界点。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM