Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF scrollview scrolled to the bottom default

I have a ScrollViewer containing a ListBox. I would like the ScrollViewer to scroll all the way to the bottom by default when the view has been loaded! This because the most recent element is always the last element in the ListBox.

Is there an easy way to achieve this behavior?

Thanks

like image 326
code-zoop Avatar asked Apr 27 '10 10:04

code-zoop


2 Answers

If you have access to the ScrollViewer, you could also use the ScrollViewer.ScrollToBottom() method.

like image 109
gehho Avatar answered Sep 20 '22 03:09

gehho


Yes, there is a easy way.

lv.ScrollIntoView(lv.Items[0]);

This will scroll to the first item. All you need to do is to find your last item.

like image 31
TalkingCode Avatar answered Sep 21 '22 03:09

TalkingCode