Automatically Scroll to the last Item in ListBox

2 posts, 0 answers
  1. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 10 Sep 2014 Link to this post

    Hi,

    i have a little application running as trayicon. Here i use a RadListBox to add some informations for the user.

    In my code behind:
    var item1 = new RadListBoxItem() { Content = "Start Sync" +  Convert.ToString(i)};
    results.Items.Add(item1);

    works fine. But how do i scroll down to the latest added item in my ListBox?

    Thanks a lot, best Regards
    Rene
  2. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 10 Sep 2014 Link to this post

    Hi Rene,

    In order to scroll the ListBox you can use the ScrollIntoView method of the control. You would need to just pass the index of the desired item (last index in your case) as shown below:

    this.listBox.ScrollIntoView(this.listBox.Items.Count - 1);

    Hope this helps.

    Regards,
    Kalin
    Telerik
     
    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. UI for WPF is Visual Studio 2017 Ready
Back to Top