private void listbox1_MouseMove(object sender, MouseEventArgs e)
{
if (Result[0] == "1")
{
//获取listbox的子类型ScrollViewer
ScrollViewer scrollViewer = FindChildOfType<ScrollViewer>((ListBox)sender);
if (scrollViewer == null)
{
throw new InvalidOperationException("erro");
}
else
{
//判断当前滚动的高度是否大于或者等于scrollViewer实际可滚动高度,如果等于或者大于就证明到底了
if ((scrollViewer.VerticalOffset + 1) >= scrollViewer.ScrollableHeight)
{
MessageBox.Show("aaa");
}
}
}
}
//获取子类型
public static T FindChildOfType<T>(DependencyObject root) where T : class
{
var queue = new Queue<DependencyObject>();
queue.Enqueue(root);
while (queue.Count > 0)
{
DependencyObject current = queue.Dequeue();
for (int i = VisualTreeHelper.GetChildrenCount(current) - 1; 0 <= i; i--)
{
var child = VisualTreeHelper.GetChild(current, i);
var typedChild = child as T;
if (typedChild != null)
{
return typedChild;
}
queue.Enqueue(child);
}
}
return null;
}Windows Phone开发之 listbox分页加载数据
最新推荐文章于 2022-04-18 11:02:58 发布
本文介绍了一种使用C#实现的方法,用于检测ListBox滚动条是否已经到达底部。通过获取ListBox内部的ScrollViewer组件,并监测其滚动位置,可以在滚动到底部时触发特定操作。

89

被折叠的 条评论
为什么被折叠?



