其他分享
首页 > 其他分享> > WPF DataGrid下滑动态加载数据

WPF DataGrid下滑动态加载数据

作者:互联网

效果如图:

重点是判断滑动到DataGrid底端(VerticalOffset等于ScrollableHeight),则继续加载数据

private void DataGrid_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
    var scrollViewer = e.OriginalSource as ScrollViewer;
    if (e.VerticalOffset!=0 && e.VerticalOffset == scrollViewer.ScrollableHeight)
    {
        GenerateData();
    }
}

示例代码

LoadingDataAsync

参考资料

WPF ScrollViewer panning

标签:VerticalOffset,ScrollViewer,DataGrid,ScrollableHeight,WPF,加载,scrollViewer
来源: https://www.cnblogs.com/Lulus/p/12516721.html