This is a migrated thread and some comments may be shown as answers.

Retain scroll position when adding new items at the top of the list

16 Answers 303 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nadeem
Top achievements
Rank 1
Nadeem asked on 27 Feb 2012, 10:23 PM
I am currently trying out the WP UI controls and I was hoping the DataBound ListBox would have a feature to retain scroll position once new items are added to the top of the list.

I pull data from the internet to populate my ListBox and I automatically fetch new data every couple of minutes. Upon adding new items, the ListBox items will be pushed down which confuses the user who is already checking items down the list.

I hope this is achievable. If yes I think I will buy the kit right away... looks promising.

regards,
Nadeem

16 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 29 Feb 2012, 04:27 PM
Hi Nadeem,

Thanks for contacting us and for your interest in RadControls for Windows Phone.

In fact, the behavior that you currently observe is the scroll position being retained when new items are added. The idea here is that if we consider the scroll position be the offset of the top item in relation to the top edge of the viewport - than adding new items on the top implies offseting existing items in order to retain scrolling position which actually happens. I guess you would like to retain the position of the top visible item when adding new items on top.

This behavior is currently not available in RadDataBoundListBox. Could you please give us some further details on the scenario you would like to implement so that we can evaluate it and see how it would fit in the context of our control?

Thanks for your time and do not hesitate to get back to us in case you have further questions or need assistance.

Kind regards,
Deyan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Nadeem
Top achievements
Rank 1
answered on 04 Mar 2012, 09:02 AM
Hi Deyan,

You are right, I would like to retain the position of the top visible item when adding new items on top. Here is a scenario which is applicable in my situation. You are reading through your twitter timeline which is a list of tweets and you are now half way through the list. The app would pull new tweets in the background and would add them to the top of the list. Unfortunately, doing that would push the current item visible down which will make the user lose the position he was at. 

in code, I would have something similar to this:

public void GetNewTweets()
{
  foreach(var tweet in lib.GetNewTweets())
  {
     TweetCollection.Insert(0, tweet);
  }
}

Is this currently achievable? 

Thanks,
Nadeem
0
Deyan
Telerik team
answered on 07 Mar 2012, 10:41 AM
Hi Nadeem,

We can consider your suggestion but I cannot give an exact estimation of when or whether we are going to implement this functionality. You can try using the BrindIntoView method exposed by DataBoundListBox to focus a particular item to mimic the discussed behavior.

Let me know in case you have further questions or need assistance.

Kind regards,
Deyan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Nadeem
Top achievements
Rank 1
answered on 07 Mar 2012, 11:26 AM
Hi Deyan,

Thanks for the response. I could try that out but my attempt to do this using the default ListBox has given some performance degradation that made the solution unsuable. I will try and see if the DataBoundListBox handles this in a better manner. Having such feature built will definitely be of great help to me and others who would like to have this.

Regards,
Nadeem
0
Deyan
Telerik team
answered on 09 Mar 2012, 12:43 PM
Hello Nadeem,

As I said, we will consider the scenario and will probably extend the DataBoundListBox functionality for future releases.

For now, we will consider this thread closed.

Let us know in case you have further questions or need assistance.

Greetings,
Deyan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Doug
Top achievements
Rank 1
answered on 07 Jun 2012, 12:04 PM
I was trying to solve this by calling DataboundListbox.BringIntoView, but if I call that after I insterted the new elements it is not doing anything, but if I put that on a button and I press it manually than it works... My guess is that after I insert the elements the listbox needs some time to load that. I tried even calling DataboundListbox.BringToView in a separate thread with some delay, but that didn't help either. Also tried to do this on the collection changed event that didn't work either.

So that functionality would help me as well. I hope to hear some positive feedback in the near future. 

Best Regards
0
Deyan
Telerik team
answered on 12 Jun 2012, 07:36 AM
Hello Doug,

We will consider a possibility to allow the developer to control the Collection Changed behavior in terms of whether items will be reordered when new items are added/removed.

Do not hesitate to get back to us in case you have further questions need assistance.

Regards,
Deyan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Matt Hidinger
Top achievements
Rank 1
answered on 18 Oct 2012, 02:48 AM
This feature would be great for one of my apps as well. I am trying to hack around it right now using BringIntoView, but it makes the experience feel rather awkward.
0
Deyan
Telerik team
answered on 18 Oct 2012, 11:52 AM
Hello Matt,

Thanks for writing.

It seems that the demand for such feature is increasing and therefore we will put it on our TODO list for the next major release (most probably Q3 2012 SP1).

Let us know if you have further feedback or need assistance.

Kind regards,
Deyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Doug
Top achievements
Rank 1
answered on 02 Nov 2012, 04:13 PM
Hi

So Q3 is out. But it seems to me that it is still working the same way.

I am using the pull to refresh option of the Listbox, and trying to insert items to the top of the list, and I would also like to show the item I was showing before the datarequest happened.

I got an exception when I'm trying to use the bring to view function.

// in constructor
Items.add("Viewed item")
 
 private void listBoxDatarequested(object sender, EventArgs e)
        {
            FrameworkElement lastViewvedItem = null;
            if (listBox.ViewportItems != null)
            {
                lastViewvedItem = listBox.ViewportItems[0];
            }
 
            for (int i = 0; i < 10; i++)
            {
                Items.Insert(string.Format("item {0}", i));
            }
 
 
            if (lastViewvedItem != null) listBox.BringIntoView(lastViewvedItem); // exception here
        }

So how is this working now?

Best Regards Doug
0
Deyan
Telerik team
answered on 05 Nov 2012, 03:59 PM
Hi Doug,

Thanks for writing back.

As mentioned this feature is expected for Q3 2012 SP1.

Let me know if you have further questions.

Regards,
Deyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Doug
Top achievements
Rank 1
answered on 06 Nov 2012, 12:55 PM
And when is that coming out?
0
Kiril Stanoev
Telerik team
answered on 07 Nov 2012, 09:27 AM
Hello Doug,

We've scheduled our Q3 2012 Service Pack for the first week of December 2012. 

Regards,
Kiril Stanoev
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Alex
Top achievements
Rank 1
answered on 06 Feb 2014, 05:36 PM
Kiril, did you complete the planned work?
0
Deyan
Telerik team
answered on 10 Feb 2014, 12:45 PM
Hello Alex,

This feature is already long on our Feature List.

Take a look at the ReorderMode property in the StackVirtualizationStrategyDefinition section:

http://www.telerik.com/help/windows-phone/raddataboundlistbox-features-virtualizationstrategies.html

I hope this helps.

Regards,
Deyan
Telerik
If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
0
Alex
Top achievements
Rank 1
answered on 10 Feb 2014, 04:18 PM
That's not exactly what I need.
I would like my list to stay at the same scroll position when I update the whole collection (change it to a new one with same size).

Thank you for pointing me to the ReorderMode.
Tags
DataBoundListBox
Asked by
Nadeem
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Nadeem
Top achievements
Rank 1
Doug
Top achievements
Rank 1
Matt Hidinger
Top achievements
Rank 1
Kiril Stanoev
Telerik team
Alex
Top achievements
Rank 1
Share this question
or