Ejemplo n.º 1
0
        private static void element_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var element = (UIElement)sender;

            // find the ReoderListBox parent of the element
            var reorderListBox = TreeHelpers.FindParent <ReorderListBox>(element);

            if (reorderListBox != null)
            {
                // find the ItemContainer
                FrameworkElement f = TreeHelpers.GetItemContainerFromChildElement(reorderListBox, element) as FrameworkElement;
                if (f != null)
                {
                    reorderListBox.BeginDrag(f);
                }
            }
        }
Ejemplo n.º 2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (m_isDragging && m_dragAdorner != null)
            {
                // update the position of the adorner

                var current = e.GetPosition(this);
                m_dragAdorner.OffsetX = current.X - m_mouseDown.X;
                m_dragAdorner.OffsetY = current.Y - m_mouseDown.Y;

                // find the item that we are dragging over
                var element = this.InputHitTest(new Point(e.GetPosition(this).X, e.GetPosition(this).Y)) as UIElement;

                if (element != null)
                {
                    var itemOver = TreeHelpers.GetItemContainerFromChildElement(this, element) as FrameworkElement;

                    if (itemOver != null)
                    {
                        var p = Mouse.GetPosition(itemOver);
                        var q = PointToQuadrant(itemOver, p);

                        if (itemOver != m_lastMouseOverItem || q != m_lastMouseOverQuadrant)
                        {
                            if (q == ReorderQuadrant.BottomLeft || q == ReorderQuadrant.BottomRight)
                            {
                                m_lastMoveOverPlacement = ReorderPlacement.After;
                            }
                            else
                            {
                                m_lastMoveOverPlacement = ReorderPlacement.Before;
                            }
                            PreviewInsert(itemOver, m_lastMoveOverPlacement);
                            m_lastMouseOverItem     = itemOver;
                            m_lastMouseOverQuadrant = q;
                        }
                    }
                }
            }

            base.OnMouseMove(e);
        }