windows phone开发之 listbox分页加载数据
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
{
//www.zzzyk.com 判断当前滚动的高度是否大于或者等于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;
}
摘自 fengyarongaa
补充:移动开发 , Windows Phone ,