How to detect if the scroll viewer reaches bottom in winrt

后端 未结 2 1113
执念已碎
执念已碎 2021-01-04 20:34

I\'m wondering what\'s the best approach to detect if a ScrollViewer reaches the bottom, right etc.

I think I can achieve that by using both PointerWheelChanged for

2条回答
  •  甜味超标
    2021-01-04 20:59

    XAML:

    
        
    
    

    Code behind:

    private void OnScrollViewerViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
    {
        var verticalOffset = sv.VerticalOffset;
        var maxVerticalOffset = sv.ScrollableHeight; //sv.ExtentHeight - sv.ViewportHeight;
    
        if (maxVerticalOffset < 0 ||
            verticalOffset == maxVerticalOffset)
        {
            // Scrolled to bottom
            rect.Fill = new SolidColorBrush(Colors.Red);
        }
        else
        {
            // Not scrolled to bottom
            rect.Fill = new SolidColorBrush(Colors.Yellow);
        }
    }
    

提交回复
热议问题