Auto Scroll To New Item inside Scrollviewer

2 posts, 0 answers
  1. heavywoody
    heavywoody avatar
    79 posts
    Member since:
    Oct 2009

    Posted 10 May 2014 Link to this post

    I have a usercontrol that has a Listbox of Listboxes.   That usercontrol is put inside a Scrollviewer.   I have made a sample application I have attached a link to.  My real version uses MVVM, so please keep that in mind.   What I am trying to accomplish is if a new item is added to the listboxes in the Usercontrol, how can I make the Scrollviewer on the MainWindow scroll to where the new item was just added add the end of whatever listbox it was added?

  2. Kalin
    Kalin avatar
    1191 posts

    Posted 12 May 2014 Link to this post

    Hello Christian,

    In order to achieve the desired functionality in the specific scenario you would need to manually move the ScrollViewer to the needed location by using its ScrollToHorizontalOffset method. However you would also need to manually calculate how much to scroll in order to show the last item of each ListBox. For your convenience I have modified the provided project in order to demonstrate the exact approach.

    Hope this helps.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. DevCraft banner
Back to Top