I know Windows.Community.Toolkit has a QuickReturn
ScrollHeader
. But that's for the Header
only because the collapsing direction for the footer is different from the header.
How can I make a quick return footer for the ListView
? I am looking for some scrolling event that would help me to do this.
You can try to use the ScrollViewer
to wrap the ListView
to get the scroll event of the ScrollViewer.
xaml
<Grid>
<ScrollViewer ViewChanged="ScrollViewer_ViewChanged" VerticalAlignment="Stretch">
<ListView>
...
</ListView>
</ScrollViewer>
</Grid>
xaml.cs
private double scrollLocation = 0;
private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
{
var viewer = sender as ScrollViewer;
if (viewer.VerticalOffset > scrollLocation + 3)
{
// scroll down, show the footer
}
else if (viewer.VerticalOffset < scrollLocation - 3)
{
// scroll up, hide the footer
}
scrollLocation = viewer.VerticalOffset;
}
By listening to the ScrollViewer's ViewChanged
event, you can determine the scroll direction, and the reason is +3
, -3
, mainly to eliminate the unconscious scrolling of the mouse or touch, reduce false positives.
Best regards.