비슷한 일을 알아 내려고 후 나는 (그것을 다른 답변보다 쉽게 보인다) 나는 여기에 내 결과를 공유하는 것이라고 생각, 도움이된다면 당신은 모양을 가질 수있다
간단한 가시성 테스트는 내가 here에서 가져 왔습니다.
private static bool IsUserVisible(FrameworkElement element, FrameworkElement container)
{
if (!element.IsVisible)
return false;
Rect bounds =
element.TransformToAncestor(container).TransformBounds(new Rect(0.0, 0.0, element.ActualWidth, element.ActualHeight));
var rect = new Rect(0.0, 0.0, container.ActualWidth, container.ActualHeight);
return rect.Contains(bounds.TopLeft) || rect.Contains(bounds.BottomRight);
}
는 그 후 당신은 ListBoxItems을 반복하고 볼 수있는 결정하기 위해이 테스트를 사용할 수 있습니다.
private List<object> GetVisibleItemsFromListbox(ListBox listBox, FrameworkElement parentToTestVisibility)
{
var items = new List<object>();
foreach (var item in PhotosListBox.Items)
{
if (IsUserVisible((ListBoxItem)listBox.ItemContainerGenerator.ContainerFromItem(item), parentToTestVisibility))
{
items.Add(item);
}
else if (items.Any())
{
break;
}
}
return items;
}
당신은 여기에 답이 있습니다 항목 선택이 자동으로 항목이 표시 의미 왜 http://stackoverflow.com/questions/11187382/get-listview-visible-items – GameAlchemist