Why won't my ListView scroll using ScrollIntoView?

  • Thread starter Windows Central Question
  • Start date
W

Windows Central Question

ListView won't scroll using ScrollIntoView

For some reason, I cannot get the ScrollIntoView to work for my ListView. FYI... I have added my items to my ListView manually by adding ListViewItems that custom content set for each one. Not sure that that matters.

public void GoToBottom()
{
if (lv.Items != null)
{
if (lv.Items.Count > 0)
{
lv.SelectedIndex = lstSurvey.Items.Count - 1;
lv.UpdateLayout();
lv.ScrollIntoView(lstSurvey.Items[lv.SelectedIndex], ScrollIntoViewAlignment.Default);
}
}
}
 

Rod Yager

New member
Jun 23, 2015
3
0
0
Visit site
Re: ListView won't scroll using ScrollIntoView

I am the one that started this post. I forgot to add that I am trying to get this to work on windows phone 8.1. It's not working on the emulator or on the phone. Thanks
 

Rod Yager

New member
Jun 23, 2015
3
0
0
Visit site
Re: ListView won't scroll using ScrollIntoView

Tried it. No luck. Still no movement in the scroll. I have even tried using an app bar button to call the method after the listview hs completely rendered in case it was a timing issue. I'm stumped!
 

Rod Yager

New member
Jun 23, 2015
3
0
0
Visit site
Re: ListView won't scroll using ScrollIntoView

I just solved my own problem. The issue seemed to be that the listview was a child of a scrollviewer and a stackpanel. When I removed those parent elements and put in the grid.row="1" where the scrollviewer was, it started working.

<ScrollViewer Grid.Row="1">
<StackPanel Orientation="Vertical">
<ListView x:Name="lstSurvey"/>
</StackPanel>
</ScrollViewer>
 

Members online

Forum statistics

Threads
323,311
Messages
2,243,618
Members
428,056
Latest member
Carnes