【问题标题】:Getting the coordinates of a specific ListViewItem relative to it's owning ListView获取特定 ListViewItem 相对于它拥有的 ListView 的坐标
【发布时间】:2013-01-07 04:11:55
【问题描述】:

我正在尝试确定代表 ListViewItem 的容器的物理坐标(特别是我对 TOP 和 BOTTOM 感兴趣)。

我通过以下方式引用了 ListViewItem:

 ListViewItem item = ((ListView)AdornedElement).ItemContainerGenerator.ContainerFromIndex(idx) as ListViewItem;
 ContentPresenter myContentPresenter = FindVisualChild<ContentPresenter>(item);   

我现在需要获取该项目并找出它的顶部和底部值相对于整个列表视图。这是为了在拖放过程中显示拖线指示器。

谁能提供任何见解?

谢谢

【问题讨论】:

    标签: wpf drag-and-drop listviewitem adorner adornerlayer


    【解决方案1】:

    对于将来可能会有所帮助的人。我想通了(字面意思是在我发布之后)

        Point pointTransformToVisual = lvItem.TransformToVisual((Visual)theListView.Parent).Transform(new Point());
    
        Rect boundsRect = VisualTreeHelper.GetDescendantBounds(lvItem);
        boundsRect.Offset(transform.X, transform.Y);
    

    【讨论】:

      猜你喜欢
      • 2011-11-01
      • 2014-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多