Scroll to bottom of listbox wp7?

If you simply just set the select index of the ListBox, it should work. I tried it, and it seemed to work fine.

Up vote 2 down vote favorite share g+ share fb share tw.

I have many items(0-100) end need to scroll to the bottom of Listbox which contains it. I tried: ScrollViewer. SetVerticalScrollBarVisibility(listmy, ScrollBarVisibility.

Auto); listmy. SelectedItem = listmy.Items. Count-1; listmy.

ScrollIntoView(listmy. SelectedItem); ScrollViewer. SetVerticalScrollBarVisibility(listmy, ScrollBarVisibility.

Disabled); but this doesn't workds for me. The scrollviewer wraps the listbox and textbox.(listbox vertical scroll in disabled state). UPD xaml: ... and cs: listmy.

ItemsSource = ((App)Application. Current). DIALOG; ScrollViewer.

SetVerticalScrollBarVisibility(listmy, ScrollBarVisibility. Auto); listmy. SelectedIndex = listmy.Items.

Count-1; listmy. ScrollIntoView(listmy. SelectedItem); ScrollViewer.

SetVerticalScrollBarVisibility(listmy, ScrollBarVisibility. Disabled); c# silverlight windows-phone-7 listbox scrollviewer link|improve this question edited Sep 14 '11 at 4:21 asked Sep 13 '11 at 21:13wsevendays20810 81% accept rate.

As currently worded, your question makes no sense. – Prætorian Sep 13 '11 at 21:31 Sorry, I'm not good in english. I posted code.

– wsevendays Sep 14 '11 at 4:24.

If you simply just set the select index of the ListBox, it should work. I tried it, and it seemed to work fine. ListBox1.

SelectedIndex = listBox1.Items. Count - 1; I've tried that, and it scrolled to the bottom of the ListBox, with no problems.

3 This doesn't works for me. – wsevendays Sep 14 '11 at 4:21 +1 This worked for me. – Rich C Jan 12 at 19:11.

How about this: var lastItem = listmy.Itemslistmy.Items. Count - 1; listmy. ScrollIntoView(lastItem); I tried it on a sample project and it worked great!

1 This doesn't works for me. – wsevendays Sep 22 '11 at 19:20 2 I've uploaded my sample project to chriskoenig.net/upload/ScrollToBottom70.zip. I've also verified that this works in both SDK 7.0 and SDK 7.1. Look at the sample and see if that works - if it does not, perhaps I don't understand your question after all :-) – Chris Koenig Sep 22 '11 at 21:23 I need scrolling in my project.

Sample code :ScrollViewer. SetVerticalScrollBarVisibility(listmy, ScrollBarVisibility. Auto); var lastItem = listmy.Itemslistmy.Items.

Count - 1; listmy. ScrollIntoView(lastItem); ScrollViewer. SetVerticalScrollBarVisibility(listmy, ScrollBarVisibility.

Disabled); – wsevendays Sep 23 '11 at 17:53 I guess I really don't know what you're trying to do, and putting a ListBox in a ScrollViewer just doesn't seem like a good UX metaphor to me. Is there a sample project I can download somewhere to see what you're trying to accomplish, because I'm obviously not understanding what you're trying to do... – Chris Koenig Sep 23 '11 at 22:29 I can give only xaml pastebin.com/dEwew5rL – wsevendays 7.1.0 at 16:29.

I gather you actually want to just ensure the ScrollBar of the ListBox is always fully scrolled to the bottom. The other solutions are only about making sure the last line is visible (not the same thing). To get the effect you want you can create a simple subclassed ListBox like this: using System.Windows.

Controls; namespace ScrollBarTest { public class CustomListBox : ListBox { public void ScrollToBottom() { var scrollviewer = GetTemplateChild("ScrollViewer") as ScrollViewer; scrollviewer. ScrollToVerticalOffset(scrollviewer. ScrollableHeight); } } } Do not use an outer ScrollViewer as you are in the example, just the subclassed ListBox Just call the ScrollToBottom() method whenever you want it scrolled to the last line.

The reason for the subclassing is that GetTemplateChild is protected so not accessible from outside of a derived class.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions