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

17 posts, 0 answers
  1. Nadeem
    Nadeem avatar
    3 posts
    Member since:
    May 2011

    Posted 27 Feb 2012 Link to this post

    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
  2. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 29 Feb 2012 Link to this post

    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 >>
  3. DevCraft banner
  4. Nadeem
    Nadeem avatar
    3 posts
    Member since:
    May 2011

    Posted 04 Mar 2012 Link to this post

    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
  5. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 07 Mar 2012 Link to this post

    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 >>
  6. Nadeem
    Nadeem avatar
    3 posts
    Member since:
    May 2011

    Posted 07 Mar 2012 Link to this post

    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
  7. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 09 Mar 2012 Link to this post

    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 >>
  8. Doug
    Doug avatar
    49 posts
    Member since:
    May 2012

    Posted 07 Jun 2012 Link to this post

    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
  9. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 12 Jun 2012 Link to this post

    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 >>

  10. Matt Hidinger
    Matt Hidinger avatar
    6 posts
    Member since:
    Nov 2009

    Posted 17 Oct 2012 Link to this post

    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.
  11. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 18 Oct 2012 Link to this post

    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.

  12. Doug
    Doug avatar
    49 posts
    Member since:
    May 2012

    Posted 02 Nov 2012 Link to this post

    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
  13. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 05 Nov 2012 Link to this post

    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.

  14. Doug
    Doug avatar
    49 posts
    Member since:
    May 2012

    Posted 06 Nov 2012 Link to this post

    And when is that coming out?
  15. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 07 Nov 2012 Link to this post

    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.

  16. Alex
    Alex avatar
    25 posts
    Member since:
    Mar 2011

    Posted 06 Feb 2014 in reply to Kiril Stanoev Link to this post

    Kiril, did you complete the planned work?
  17. Deyan
    Admin
    Deyan avatar
    2041 posts

    Posted 10 Feb 2014 Link to this post

    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.
  18. Alex
    Alex avatar
    25 posts
    Member since:
    Mar 2011

    Posted 10 Feb 2014 in reply to Deyan Link to this post

    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.
Back to Top
DevCraft banner