Adelaiglesia
Adelaiglesia

Reputation: 365

WP8 Listbox jumpy when loading more elements

I have been implementing infinite scroll in my app, but when the List loads more elements the ScrollView Scroll position is not in the same place than before.

The auto scroll (which works well):

private void VideosList_ItemRealized(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
    {
        ScrollViewer sv = VideosList.Descendents().OfType<ScrollViewer>().FirstOrDefault();

        if (sv != null && this.isloading == false && sv.VerticalOffset >= (sv.ScrollableHeight - 60))
        {
            this.isloading = true;
            videosList.getMoreVideos(20);
        }
        //videosList.getMoreVideos(5);
    }

The binding

public void videosListUpdateFinished(object sender, EventArgs e)
{
    YTVideoPage.Focus();
    VideosList.ItemsSource = null;
    VideosList.ItemsSource = videosList.ytvideos.data.items;
    this.isloading = false;
}

How I can get the listbox to remain in the same position when changing the binding? I've tried to get VerticalOffset and set it when load but it doesn't work.

I hope you can help me. Thank you.

Upvotes: 0

Views: 196

Answers (1)

eX0du5
eX0du5

Reputation: 896

Why don't you use the new LongListSelector for WP8? This one works quite well for infinite scrolling. There are also examples how to use this like: http://code.msdn.microsoft.com/wpapps/TwitterSearch-Windows-b7fc4e5e

Unfortunately, the twitter API has changed and you won't receive any data, but the example code still helped me to figure out how to implement it.

Upvotes: 1

Related Questions