Open hank3006 opened 8 years ago
Ok I got it working using an extension class on the scroller(found on the internet) and added a new call in PullToRefreshListView.cs
public void MyScrollerCode(object item) { var container = ((ListViewItem)(this.ContainerFromItem(item))); this.Scroller.ScrollToElement(container); }
And the extension method is:
public static void ScrollToElement(this Windows.UI.Xaml.Controls.ScrollViewer scrollViewer, UIElement element, bool isVerticalScrolling = true, bool smoothScrolling = true, float? zoomFactor = null) { var transform = element.TransformToVisual((UIElement)scrollViewer.Content); var position = transform.TransformPoint(new Windows.Foundation.Point(0, 0));
if (isVerticalScrolling)
{
scrollViewer.ChangeView(null, position.Y, zoomFactor, !smoothScrolling);
}
else
{
scrollViewer.ChangeView(position.X, null, zoomFactor, !smoothScrolling);
}
}
So there may be a better way to do it but this seems to work for me. Any input on this will be greatly appreciated. Thanks for a great project like this one! It has been working great!
My listview is set an ObservableCollection
If I make the call:
this.lstvDocuments.ScrollIntoView(NewDocumentItem);"
it does not scroll to the item. If I update the xaml control to be a regular listview, the code will scroll to the item.
I was able to duplicate the issue in the test app using your source code.
Thanks! Jeffrey