简体   繁体   中英

Auto scroll listbox wp7

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?

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

如果您使用Linq To Visual Tree之类的东西,您可以在ListBox内部的ScrollViewer中获取,然后在其上调用ScrollToVerticalOffset。

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

 list.ScrollIntoView(object item);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM