コード例 #1
0
        bool IDropTarget.CanDropElement(UIElement draggedElement)
        {
            ColumnManagerCell draggedCell = draggedElement as ColumnManagerCell;

            if ((draggedCell == null) || (this == draggedCell))
            {
                return(false);
            }

            ColumnManagerRow parentRow = this.ParentRow as ColumnManagerRow;

            if ((parentRow == null) || !parentRow.AllowColumnReorder)
            {
                return(false);
            }

            if (!ColumnManagerCell.CanMove(draggedCell) || !ColumnManagerCell.CanMove(this))
            {
                return(false);
            }

            DataGridContext draggedDetailContext = draggedCell.DataGridContext;
            DataGridContext sourceDetailContext  = this.DataGridContext;

            Debug.Assert((draggedDetailContext != null) && (sourceDetailContext != null));

            return((sourceDetailContext.SourceDetailConfiguration == draggedDetailContext.SourceDetailConfiguration) &&
                   (sourceDetailContext.GroupLevelDescriptions == draggedDetailContext.GroupLevelDescriptions));
        }
コード例 #2
0
        bool IDropTarget.CanDropElement(UIElement draggedElement, RelativePoint mousePosition)
        {
            var draggedCell = draggedElement as ColumnManagerCell;

            if ((draggedCell == null) || (this == draggedCell))
            {
                return(false);
            }

            var parentRow = this.ParentRow as ColumnManagerRow;

            if ((parentRow == null) || !parentRow.AllowColumnReorder)
            {
                return(false);
            }

            var draggedDetailContext = draggedCell.DataGridContext;
            var sourceDetailContext  = this.DataGridContext;

            Debug.Assert((draggedDetailContext != null) && (sourceDetailContext != null));

            if ((sourceDetailContext.SourceDetailConfiguration != draggedDetailContext.SourceDetailConfiguration) ||
                (sourceDetailContext.GroupLevelDescriptions != draggedDetailContext.GroupLevelDescriptions))
            {
                return(false);
            }

            if (!ColumnManagerCell.CanMove(draggedCell))
            {
                return(false);
            }

            var manager = draggedCell.DragSourceManager as ColumnReorderingDragSourceManager;

            if ((manager != null) && (manager.IsAnimatedColumnReorderingEnabled))
            {
                if (!manager.CanReorder(draggedCell, this, mousePosition))
                {
                    return(false);
                }
            }
            else
            {
                var relativePosition = mousePosition.GetPoint(this);
                var moveBefore       = (relativePosition.X <= this.ActualWidth / 2d);

                if (moveBefore)
                {
                    if (!draggedCell.CanMoveBefore(this.ParentColumn))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!draggedCell.CanMoveAfter(this.ParentColumn))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }