Is there a way to detect that ScrollViwer
of ListView
is in scrolling mode and stopped scrolling. In windows phone 8.1 ListView
we can not get reference of the scrollviewer.
Any one done it in windows phone 8.1 WinRT app?
Is there a way to detect that ScrollViwer
of ListView
is in scrolling mode and stopped scrolling. In windows phone 8.1 ListView
we can not get reference of the scrollviewer.
Any one done it in windows phone 8.1 WinRT app?
You can find the ScrollViewer of your ListView by using VisualTreeHelper. For example like this:
// method to pull out a ScrollViewer
public static ScrollViewer GetScrollViewer(DependencyObject depObj)
{
if (depObj is ScrollViewer) return depObj as ScrollViewer;
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
var child = VisualTreeHelper.GetChild(depObj, i);
var result = GetScrollViewer(child);
if (result != null) return result;
}
return null;
}
Once you have a ScrollViewer you can subscribe to its events:
GetScrollViewer(yourListView).ViewChanged += yourEvent_ViewChanged;
Once the ListView is
Loaded
you can get theScrollViewer
like this:Edit
As Romasz suggested, once you get the
ScrollViewer
, you can use itsViewChanged
event, to monitor when it is scrolling and when it stops.Also, here's the generic extension method that I use for traversing the visual tree:
To get the
ScrollViewer
using this methos, do this: