GetItemContainerFromPoint() public static method

public static GetItemContainerFromPoint ( ItemsControl itemsControl, Point p ) : UIElement
itemsControl System.Windows.Controls.ItemsControl
p Point
return UIElement
        private void DragStarted(ItemsControl itemsControl)
        {
            Type dataType = _data.GetType();

            if (!(dataType.IsSubclassOf(ItemType) || dataType == ItemType || ItemType.IsAssignableFrom(dataType)))
            {
                return;
            }

            UIElement draggedItemContainer = Helper.GetItemContainerFromPoint(itemsControl, _dragStartPosition);

            _isDragging = true;
            DataObject      dObject = new DataObject(ItemType, _data);
            DragDropEffects e       = System.Windows.DragDrop.DoDragDrop(itemsControl, dObject, DragDropEffects.Copy | DragDropEffects.Move);

            if ((e & DragDropEffects.Move) != 0)
            {
                if (draggedItemContainer != null)
                {
                    int dragItemIndex = itemsControl.ItemContainerGenerator.IndexFromContainer(draggedItemContainer);
                    Helper.RemoveItem(itemsControl, dragItemIndex);
                }
                else
                {
                    Helper.RemoveItem(itemsControl, _data);
                }
            }
            ResetState();
        }
 private void InitializeInsertAdorner(ItemsControl itemsControl, DragEventArgs e)
 {
     if (_insertAdorner == null)
     {
         var       adornerLayer  = AdornerLayer.GetAdornerLayer(itemsControl);
         UIElement itemContainer = Helper.GetItemContainerFromPoint(itemsControl, e.GetPosition(itemsControl));
         if (itemContainer != null)
         {
             bool isPointInTopHalf = Helper.IsPointInTopHalf(itemsControl, e);
             bool isItemsControlOrientationHorizontal = Helper.IsItemControlOrientationHorizontal(itemsControl);
             _insertAdorner = new InsertAdorner(isPointInTopHalf, isItemsControlOrientationHorizontal, itemContainer, adornerLayer);
         }
     }
 }
        private int FindInsertionIndex(ItemsControl itemsControl, DragEventArgs e)
        {
            UIElement dropTargetContainer = Helper.GetItemContainerFromPoint(itemsControl, e.GetPosition(itemsControl));

            if (dropTargetContainer != null)
            {
                int index = itemsControl.ItemContainerGenerator.IndexFromContainer(dropTargetContainer);
                if (Helper.IsPointInTopHalf(itemsControl, e))
                {
                    return(index);
                }
                else
                {
                    return(index + 1);
                }
            }
            return(itemsControl.Items.Count);
        }