WP 8.1 bottom to top infinite scrolling

2019-02-24 08:29发布

问题:

I have explored ISupportIncrementalLoading and seen MS sample and other examples for infinite scrolling behaviour.

But I want bottom to top scrolling where items are added on top on scrolling bottom to top.

Edit:I have found a workaround for this. I have rotated listview by 180 degree and datatemplate by 180 degree which helped me achieve desired functionality.

 <ListView x:Name="GridViewMain" IncrementalLoadingThreshold="2" RenderTransformOrigin="0.5,0.5">
        <ListView.RenderTransform>
            <RotateTransform Angle="180"></RotateTransform>
        </ListView.RenderTransform>
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            </Style>
        </ListView.ItemContainerStyle>
        <ListView.Resources>
            <DataTemplate x:Key="DataTemplateGridViewMain">
                <Grid HorizontalAlignment="Stretch" Background="#FF7C1A9B" RenderTransformOrigin="0.5,0.5">
                    <Grid.RenderTransform>
                        <RotateTransform Angle="180"/>
                    </Grid.RenderTransform>
                    <TextBlock HorizontalAlignment="Left" Text="{Binding}" VerticalAlignment="Center" FontSize="20" FontFamily="Tempus Sans ITC" />
                </Grid>
            </DataTemplate>
        </ListView.Resources>
        <ListView.ItemTemplate>
            <StaticResource ResourceKey="DataTemplateGridViewMain" />
        </ListView.ItemTemplate>
    </ListView>

Is this solution has any perf impact or is there any alternate way to do this?

回答1:

not sure if this will fit your needs, but I had to do something similar when creating a chat conversation screen, and was able to achieve this using ExtendedListView: https://www.nuget.org/packages/ExtendedListView

We load the most recent items, and use ScrollIntoView(lastMessage) to position the cursor at the bottom. Normally you would use MoreDataRequested event to get items when it scrolls to the bottom, but instead we reversed it and used the PullToRefreshRequested to simulate scrolling to the top, changing the loading template to say "loading more messages".

works pretty well for us, I hope this is helpful!