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; }