1
votes

I have a listbox of many richtextboxex in it. Now I want to enable an auto scrolling feature for it. I can't just do listBox.SelectedIndex++;in a timer or somthing, because then it will just go to the other richtextbox and I don't want that. I'd like somthing more like this

sv.ScrollToVerticalOffset(sv.VerticalOffset + 5);

which works perfectly in scroll view, can I implement the same thing to a listbox?

3

3 Answers

2
votes

Well I found what I was looking for

            ScrollViewer sv = ((VisualTreeHelper.GetChild(listBox, 0) as FrameworkElement).FindName("ScrollViewer") as ScrollViewer);
        sv.ScrollToVerticalOffset(sv.VerticalOffset + 0.004);

Thank you guys

1
votes

If you use something like Linq To Visual Tree you can get at the ScrollViewer inside the ListBox and then call ScrollToVerticalOffset on that.

0
votes

Yes you can. Here you should give the item index it automatically scrolls to the item

 list.ScrollIntoView(object item);