简体   繁体   中英

WP8 ListBox not scrolling

I'm developing a WP8 app and I have scroll problems. In my page I have a grid and two listbox. Why in your opinion? I tried also using ScrollViewer but good results.

<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

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.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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