这是一个非常简单的问题。我在scrollview中有很多堆栈面板。我希望他们在用户可见时(通过滚动)引发事件。
提前致谢。
答案 0 :(得分:2)
检查this page。它显示了如何确定您的元素是否在ScrollViewers视口中。
// position of your visual inside the scrollviewer
GeneralTransform childTransform = ContainedObject.TransformToAncestor(ScrollViewerObj);
Rect rectangle = childTransform.TransformBounds(new Rect(new Point(0,0),ContainedObject.RenderSize));
//Check if the elements Rect intersects with that of the scrollviewer's
Rect result = Rect.Intersect(new Rect(new Point(0, 0), ScrollViewerObj.RenderSize),rectangle);
//if result is Empty then the element is not in view
if (result == Rect.Empty)
{
//....
}
else
{
//obj is partially Or completely visible
//skip or bring obj in view.
}