// Token: 0x06005D0C RID: 23820 RVA: 0x001A2E74 File Offset: 0x001A1074
        private void StartColumnHeaderDrag()
        {
            this._columnHeaderDragStartPosition = this._columnHeaderDragCurrentPosition;
            DragStartedEventArgs e = new DragStartedEventArgs(this._columnHeaderDragStartPosition.X, this._columnHeaderDragStartPosition.Y);

            this.ParentDataGrid.OnColumnHeaderDragStarted(e);
            DataGridColumnReorderingEventArgs dataGridColumnReorderingEventArgs = new DataGridColumnReorderingEventArgs(this._draggingSrcColumnHeader.Column);

            this._columnHeaderDragIndicator                         = this.CreateColumnHeaderDragIndicator();
            this._columnHeaderDropLocationIndicator                 = this.CreateColumnHeaderDropIndicator();
            dataGridColumnReorderingEventArgs.DragIndicator         = this._columnHeaderDragIndicator;
            dataGridColumnReorderingEventArgs.DropLocationIndicator = this._columnHeaderDropLocationIndicator;
            this.ParentDataGrid.OnColumnReordering(dataGridColumnReorderingEventArgs);
            if (!dataGridColumnReorderingEventArgs.Cancel)
            {
                this._isColumnHeaderDragging            = true;
                this._columnHeaderDragIndicator         = dataGridColumnReorderingEventArgs.DragIndicator;
                this._columnHeaderDropLocationIndicator = dataGridColumnReorderingEventArgs.DropLocationIndicator;
                if (this._columnHeaderDragIndicator != null)
                {
                    this.SetDefaultsOnDragIndicator();
                    base.AddVisualChild(this._columnHeaderDragIndicator);
                }
                if (this._columnHeaderDropLocationIndicator != null)
                {
                    this.SetDefaultsOnDropIndicator();
                    base.AddVisualChild(this._columnHeaderDropLocationIndicator);
                }
                this._draggingSrcColumnHeader.SuppressClickEvent = true;
                base.InvalidateMeasure();
                return;
            }
            this.FinishColumnHeaderDrag(true);
        }
Exemplo n.º 2
0
        private void ComparisonGrid_ColumnReordering(object sender, DataGridColumnReorderingEventArgs e)
        {
            if (e.Column.DisplayIndex == 0)
            {
                e.Cancel = true;
            }

            _reorderingColumnPreviousDisplayIndex = e.Column.DisplayIndex;
        }
        private void OnMouseMove_BeginReorder(Point mousePosition)
        {
            DataGridColumnHeader dragIndicator = new DataGridColumnHeader();

            dragIndicator.OwningColumn    = this.OwningColumn;
            dragIndicator.IsEnabled       = false;
            dragIndicator.Content         = this.Content;
            dragIndicator.ContentTemplate = this.ContentTemplate;

            Control dropLocationIndicator = new ContentControl();

            dropLocationIndicator.SetStyleWithType(this.OwningGrid.DropLocationIndicatorStyle);

            if (this.OwningColumn.DragIndicatorStyle != null)
            {
                dragIndicator.SetStyleWithType(this.OwningColumn.DragIndicatorStyle);
            }
            else if (this.OwningGrid.DragIndicatorStyle != null)
            {
                dragIndicator.SetStyleWithType(this.OwningGrid.DragIndicatorStyle);
            }

            // If the user didn't style the dragIndicator's Width, default it to the column header's width
            if (double.IsNaN(dragIndicator.Width))
            {
                dragIndicator.Width = this.ActualWidth;
            }

            // If the user didn't style the dropLocationIndicator's Height, default to the column header's height
            if (double.IsNaN(dropLocationIndicator.Height))
            {
                dropLocationIndicator.Height = this.ActualHeight;
            }

            // pass the caret's data template to the user for modification
            DataGridColumnReorderingEventArgs columnReorderingEventArgs = new DataGridColumnReorderingEventArgs(this.OwningColumn)
            {
                DropLocationIndicator = dropLocationIndicator,
                DragIndicator         = dragIndicator
            };

            this.OwningGrid.OnColumnReordering(columnReorderingEventArgs);
            if (columnReorderingEventArgs.Cancel)
            {
                return;
            }

            // The user didn't cancel, so prepare for the reorder
            _dragColumn = this.OwningColumn;
            _dragMode   = DragMode.Reorder;
            _dragStart  = mousePosition;

            // Display the reordering thumb
            this.OwningGrid.ColumnHeaders.DragColumn            = this.OwningColumn;
            this.OwningGrid.ColumnHeaders.DragIndicator         = columnReorderingEventArgs.DragIndicator;
            this.OwningGrid.ColumnHeaders.DropLocationIndicator = columnReorderingEventArgs.DropLocationIndicator;
        }
Exemplo n.º 4
0
 protected override void OnColumnReordering(DataGridColumnReorderingEventArgs e)
 {
     base.OnColumnReordering(e);
     // Check if the reordering column is the last column
     if (e.Column.DisplayIndex == this.Columns.Count - 1)
     {
         // This is the last column, therefore abort reordering
         e.Cancel = true;
     }
 }
        /// <summary>
        ///     Method which start the column header drag. Includes raising events and creating default ghosts
        /// </summary>
        private void StartColumnHeaderDrag()
        {
            Debug.Assert(ParentDataGrid != null, "ParentDataGrid is null");

            _columnHeaderDragStartPosition = _columnHeaderDragCurrentPosition;
            DragStartedEventArgs dragStartedEventArgs = new DragStartedEventArgs(_columnHeaderDragStartPosition.X, _columnHeaderDragStartPosition.Y);

            ParentDataGrid.OnColumnHeaderDragStarted(dragStartedEventArgs);

            DataGridColumnReorderingEventArgs reorderingEventArgs = new DataGridColumnReorderingEventArgs(_draggingSrcColumnHeader.Column);

            _columnHeaderDragIndicator         = CreateColumnHeaderDragIndicator();
            _columnHeaderDropLocationIndicator = CreateColumnHeaderDropIndicator();

            reorderingEventArgs.DragIndicator         = _columnHeaderDragIndicator;
            reorderingEventArgs.DropLocationIndicator = _columnHeaderDropLocationIndicator;
            ParentDataGrid.OnColumnReordering(reorderingEventArgs);

            if (!reorderingEventArgs.Cancel)
            {
                _isColumnHeaderDragging            = true;
                _columnHeaderDragIndicator         = reorderingEventArgs.DragIndicator;
                _columnHeaderDropLocationIndicator = reorderingEventArgs.DropLocationIndicator;

                if (_columnHeaderDragIndicator != null)
                {
                    SetDefaultsOnDragIndicator();
                    AddVisualChild(_columnHeaderDragIndicator);
                }

                if (_columnHeaderDropLocationIndicator != null)
                {
                    SetDefaultsOnDropIndicator();
                    AddVisualChild(_columnHeaderDropLocationIndicator);
                }

                _draggingSrcColumnHeader.SuppressClickEvent = true;
                InvalidateMeasure();
            }
            else
            {
                FinishColumnHeaderDrag(true);
            }
        }
Exemplo n.º 6
0
 protected internal virtual void OnColumnReordering(DataGridColumnReorderingEventArgs e)
 {
     if (ColumnReordering != null)
     {
         ColumnReordering(this, e);
     }
 }
        private void OnPointerMove_BeginReorder(uint pointerId, Point pointerPosition)
        {
            Debug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");

            DataGridColumnHeader dragIndicator = new DataGridColumnHeader();

            dragIndicator.OwningColumn    = this.OwningColumn;
            dragIndicator.IsEnabled       = false;
            dragIndicator.Content         = this.Content;
            dragIndicator.ContentTemplate = this.ContentTemplate;

            Control dropLocationIndicator = new ContentControl();

            dropLocationIndicator.SetStyleWithType(this.OwningGrid.DropLocationIndicatorStyle);

            if (this.OwningColumn.DragIndicatorStyle != null)
            {
                dragIndicator.SetStyleWithType(this.OwningColumn.DragIndicatorStyle);
            }
            else if (this.OwningGrid.DragIndicatorStyle != null)
            {
                dragIndicator.SetStyleWithType(this.OwningGrid.DragIndicatorStyle);
            }

            // If the user didn't style the dragIndicator's Width, default it to the column header's width.
            if (double.IsNaN(dragIndicator.Width))
            {
                dragIndicator.Width = this.ActualWidth;
            }

            // If the user didn't style the dropLocationIndicator's Height, default to the column header's height.
            if (double.IsNaN(dropLocationIndicator.Height))
            {
                dropLocationIndicator.Height = this.ActualHeight;
            }

            // pass the caret's data template to the user for modification.
            DataGridColumnReorderingEventArgs columnReorderingEventArgs = new DataGridColumnReorderingEventArgs(this.OwningColumn)
            {
                DropLocationIndicator = dropLocationIndicator,
                DragIndicator         = dragIndicator
            };

            this.OwningGrid.OnColumnReordering(columnReorderingEventArgs);
            if (columnReorderingEventArgs.Cancel)
            {
                return;
            }

            DataGridColumnHeaderInteractionInfo interactionInfo = this.OwningGrid.ColumnHeaderInteractionInfo;

            // The app didn't cancel, so prepare for the reorder.
            interactionInfo.DragColumn = this.OwningColumn;
            Debug.Assert(interactionInfo.DragMode != DragMode.None, "Expected _dragMode other than None.");
            interactionInfo.DragMode      = DragMode.Reorder;
            interactionInfo.DragPointerId = pointerId;
            interactionInfo.DragStart     = pointerPosition;

            // Display the reordering thumb.
            this.OwningGrid.ColumnHeaders.DragColumn            = this.OwningColumn;
            this.OwningGrid.ColumnHeaders.DragIndicator         = columnReorderingEventArgs.DragIndicator;
            this.OwningGrid.ColumnHeaders.DropLocationIndicator = columnReorderingEventArgs.DropLocationIndicator;
        }
 private void dataGrid_ColumnReordering(object sender, DataGridColumnReorderingEventArgs e)
 {
     currentCellElement = CurrentCellContainer;
 }
Exemplo n.º 9
0
        private void OnMouseMove_BeginReorder(Point mousePosition, Point mousePositionGridParent)
        {
            DataGridColumnHeader dragIndicator = new DataGridColumnHeader();

            dragIndicator.OwningColumn    = this.OwningColumn;
            dragIndicator.IsEnabled       = false;
            dragIndicator.Content         = this.Content;
            dragIndicator.ContentTemplate = this.ContentTemplate;

            if (this.OwningColumn.DragIndicatorStyle != null)
            {
                dragIndicator.SetStyleWithType(this.OwningColumn.DragIndicatorStyle);
            }
            else if (this.OwningGrid.DragIndicatorStyle != null)
            {
                dragIndicator.SetStyleWithType(this.OwningGrid.DragIndicatorStyle);
            }

            // If the user didn't style the dragIndicator's Width, default it to the column header's width
            if (double.IsNaN(dragIndicator.Width))
            {
                dragIndicator.Width = this.ActualWidth;
            }

            // If the user didn't style the dropLocationIndicator's Height, default to the column header's height
            if (double.IsNaN(this.OwningGrid.ColumnDropLocationIndicator.Height))
            {
                this._autoSizeDropLocationIndicatorHeight          = true;
                this.OwningGrid.ColumnDropLocationIndicator.Height = this.ActualHeight;
            }

            // pass the caret's data template to the user for modification
            DataGridColumnReorderingEventArgs columnReorderingEventArgs = new DataGridColumnReorderingEventArgs(this.OwningColumn)
            {
                DropLocationIndicator = this.OwningGrid.ColumnDropLocationIndicator,
                DragIndicator         = dragIndicator
            };

            this.OwningGrid.OnColumnReordering(columnReorderingEventArgs);
            if (columnReorderingEventArgs.Cancel)
            {
                return;
            }

            // The user didn't cancel, so prepare for the reorder
            _dragColumn      = this.OwningColumn;
            _dragMode        = DragMode.Reorder;
            _dragStartParent = mousePositionGridParent;
            // the mouse position relative to the ColumnHeader needs to be scaled to be in the same
            // dimensions as the DataGrid, so that it doesn't get out of sync later on
            _dragStart = this.OwningGrid.RenderTransform.Transform(mousePosition);

            // Display the reordering thumb
            if (_reorderingThumb == null)
            {
                _reorderingThumb = new Popup();
            }

            _reorderingThumb.Child  = columnReorderingEventArgs.DragIndicator;
            _reorderingThumb.IsOpen = true;

            // use the data template to populate the caret
            if (columnReorderingEventArgs.DropLocationIndicator != null)
            {
                Control child = columnReorderingEventArgs.DropLocationIndicator;

                this.OwningGrid.ColumnDropLocationIndicatorPopup.Child  = child;
                this.OwningGrid.ColumnDropLocationIndicatorPopup.Height = child.ActualHeight;
                this.OwningGrid.ColumnDropLocationIndicatorPopup.Width  = child.ActualWidth;

                this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false;
            }
        }
Exemplo n.º 10
0
        private void OnMouseMove_Reorder(ref bool handled, Point mousePosition, Point mousePositionHeaders, Point mousePositionGrid, Point mousePositionGridParent, double distanceFromLeft, double distanceFromRight)
        {
            if (handled)
            {
                return;
            }

            #region handle entry into reorder mode
            if (_dragMode == DragMode.MouseDown && _dragColumn == null && (distanceFromRight > DATAGRIDCOLUMNHEADER_resizeRegionWidth && distanceFromLeft > DATAGRIDCOLUMNHEADER_resizeRegionWidth))
            {
                DragStartedEventArgs dragStartedEventArgs = new DragStartedEventArgs(mousePositionGrid.X - _lastMousePositionGrid.Value.X, mousePositionGrid.Y - _lastMousePositionGrid.Value.Y);
                this.OwningGrid.OnColumnHeaderDragStarted(dragStartedEventArgs);

                handled = CanReorderColumn(this.OwningColumn);

                if (handled)
                {
                    DataGridColumnHeader dragIndicator = new DataGridColumnHeader();
                    dragIndicator.OwningColumn = this.OwningColumn;
                    dragIndicator.IsEnabled = false;
                    dragIndicator.Content = this.Content;
                    dragIndicator.ContentTemplate = this.ContentTemplate;

                    if (this.OwningGrid.DragIndicatorStyle != null)
                    {
                        dragIndicator.Style = this.OwningGrid.DragIndicatorStyle;
                    }

                    // If the user didn't style the dragIndicator's Width, default it to the column header's width
                    if (double.IsNaN(dragIndicator.Width))
                    {
                        dragIndicator.Width = this.ActualWidth;
                    }

                    // If the user didn't style the dropLocationIndicator's Height, default to the column header's height
                    // 



                    if (double.IsNaN(this.OwningGrid.ColumnDropLocationIndicator.Height))
                    {
                        this.OwningGrid.ColumnDropLocationIndicator.Height = this.ActualHeight;
                    }

                    // pass the caret's data template to the user for modification
                    DataGridColumnReorderingEventArgs columnReorderingEventArgs = new DataGridColumnReorderingEventArgs(this.OwningColumn)
                    {
                        DropLocationIndicator = this.OwningGrid.ColumnDropLocationIndicator,
                        DragIndicator = dragIndicator
                    };
                    this.OwningGrid.OnColumnReordering(columnReorderingEventArgs);
                    if (columnReorderingEventArgs.Cancel)
                    {
                        return;
                    }

                    // The user didn't cancel, so prepare for the reorder
                    _dragColumn = this.OwningColumn;
                    _dragMode = DragMode.Reorder;
                    _dragStartParent = mousePositionGridParent;
                    // the mouse position relative to the ColumnHeader needs to be scaled to be in the same
                    // dimensions as the DataGrid, so that it doesn't get out of sync later on
                    _dragStart = this.OwningGrid.RenderTransform.Transform(mousePosition);

                    // Display the reordering thumb
                    if (_reorderingThumb == null)
                    {
                        _reorderingThumb = new Popup();
                    }

                    _reorderingThumb.Child = columnReorderingEventArgs.DragIndicator;
                    _reorderingThumb.IsOpen = true;

                    // use the data template to populate the caret
                    if (columnReorderingEventArgs.DropLocationIndicator != null)
                    {
                        Control child = columnReorderingEventArgs.DropLocationIndicator;

                        this.OwningGrid.ColumnDropLocationIndicatorPopup.Child = child;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.Height = child.ActualHeight;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.Width = child.ActualWidth;

                        this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false;
                    }
                }
            }
            #endregion

            #region handle reorder mode (eg, positioning of the popup)
            if (_dragMode == DragMode.Reorder && _reorderingThumb != null)
            {
                DragDeltaEventArgs dragDeltaEventArgs = new DragDeltaEventArgs(mousePositionGrid.X - _lastMousePositionGrid.Value.X, mousePositionGrid.Y - _lastMousePositionGrid.Value.Y);
                this.OwningGrid.OnColumnHeaderDragDelta(dragDeltaEventArgs);

                _reorderingThumb.HorizontalOffset = mousePositionGridParent.X - _dragStart.Value.X;
                _reorderingThumb.VerticalOffset = _dragStartParent.Value.Y - _dragStart.Value.Y;

                // the mouse position relative to the ColumnHeadersPresenter can be scaled differently than
                // the same position relative to the DataGrid, so apply the grid's RenderTransform
                Point scaledMousePositionHeaders = this.OwningGrid.RenderTransform.Transform(mousePositionHeaders);

                // prepare some variables for clipping/hiding
                double dgX = mousePositionGridParent.X - scaledMousePositionHeaders.X;
                double dgY = mousePositionGridParent.Y - scaledMousePositionHeaders.Y;
                double dgW = this.OwningGrid.CellsWidth;
                double dgH = this.OwningGrid.CellsHeight + this.OwningGrid.ColumnHeaders.ActualHeight;

                // we need to transform the size of the clipping rectangle if the datagrid has a rendertransform set
                Point clipSize = new Point(dgW, dgH);
                clipSize = this.OwningGrid.RenderTransform.Transform(clipSize);

                // clip the thumb to the column headers region
                _reorderingThumb.Child.Clip = new RectangleGeometry
                {
                    Rect = new Rect(
                        dgX - _reorderingThumb.HorizontalOffset,
                        dgY - _reorderingThumb.VerticalOffset,
                        clipSize.X,
                        clipSize.Y
                        )
                };

                // if the datagrid has a scale transform, apply the inverse to the popup's clipping rectangle
                ScaleTransform scaleTransform = null;
                ScaleTransform gridScaleTransform = _reorderingThumb.Child.RenderTransform as ScaleTransform;
                if (gridScaleTransform != null && gridScaleTransform.ScaleY != 0.0 && gridScaleTransform.ScaleX != 0.0)
                {
                    scaleTransform = new ScaleTransform();
                    scaleTransform.ScaleX = 1.0 / gridScaleTransform.ScaleX;
                    scaleTransform.ScaleY = 1.0 / gridScaleTransform.ScaleY;
                }
                if (scaleTransform != null)
                {
                    _reorderingThumb.Child.Clip.Transform = scaleTransform;
                }

                // Find header we're hovering over
                DataGridColumn targetColumn = this.GetReorderingTargetColumn(mousePosition, true /* ignoreVertical */, true /* clipToVisible */);

                if (this.OwningGrid.ColumnDropLocationIndicator != null)
                {
                    if (targetColumn == this.OwningGrid.ColumnsInternal.FillerColumn)
                    {
                        // change target column to last column but position caret at the end

                        targetColumn = this.OwningGrid.ColumnsInternal.LastVisibleColumn;

                        Point targetPosition = this.OwningGrid.RenderTransform.Transform(this.Translate(targetColumn.HeaderCell, mousePosition));

                        this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = true;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset = mousePositionGridParent.X - targetPosition.X + targetColumn.HeaderCell.ActualWidth;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.VerticalOffset = mousePositionGridParent.Y - targetPosition.Y;
                    }
                    else if (targetColumn != null)
                    {
                        // try to position caret

                        Point targetPosition = this.OwningGrid.RenderTransform.Transform(this.Translate(targetColumn.HeaderCell, mousePosition));

                        this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = true;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset = mousePositionGridParent.X - targetPosition.X;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.VerticalOffset = mousePositionGridParent.Y - targetPosition.Y;
                    }
                    else
                    {
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false;
                    }

                    // hide the caret if it's off the grid -- this is not the same as clipping
                    if (this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset < dgX
                        || dgX + clipSize.X < this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset)
                    {
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false;
                    }
                }

                handled = true;
            }
            #endregion
        }
Exemplo n.º 11
0
        private void OnMouseMove_Reorder(ref bool handled, Point mousePosition, Point mousePositionHeaders, Point mousePositionGrid, Point mousePositionGridParent, double distanceFromLeft, double distanceFromRight)
        {
            if (handled)
            {
                return;
            }

            #region handle entry into reorder mode
            if (_dragMode == DragMode.MouseDown && _dragColumn == null && (distanceFromRight > DATAGRIDCOLUMNHEADER_resizeRegionWidth && distanceFromLeft > DATAGRIDCOLUMNHEADER_resizeRegionWidth))
            {
                DragStartedEventArgs dragStartedEventArgs = new DragStartedEventArgs(mousePositionGrid.X - _lastMousePositionGrid.Value.X, mousePositionGrid.Y - _lastMousePositionGrid.Value.Y);
                this.OwningGrid.OnColumnHeaderDragStarted(dragStartedEventArgs);

                handled = CanReorderColumn(this.OwningColumn);

                if (handled)
                {
                    DataGridColumnHeader dragIndicator = new DataGridColumnHeader();
                    dragIndicator.OwningColumn    = this.OwningColumn;
                    dragIndicator.IsEnabled       = false;
                    dragIndicator.Content         = this.Content;
                    dragIndicator.ContentTemplate = this.ContentTemplate;

                    if (this.OwningGrid.DragIndicatorStyle != null)
                    {
                        dragIndicator.Style = this.OwningGrid.DragIndicatorStyle;
                    }

                    // If the user didn't style the dragIndicator's Width, default it to the column header's width
                    if (double.IsNaN(dragIndicator.Width))
                    {
                        dragIndicator.Width = this.ActualWidth;
                    }

                    // If the user didn't style the dropLocationIndicator's Height, default to the column header's height
                    //



                    if (double.IsNaN(this.OwningGrid.ColumnDropLocationIndicator.Height))
                    {
                        this.OwningGrid.ColumnDropLocationIndicator.Height = this.ActualHeight;
                    }

                    // pass the caret's data template to the user for modification
                    DataGridColumnReorderingEventArgs columnReorderingEventArgs = new DataGridColumnReorderingEventArgs(this.OwningColumn)
                    {
                        DropLocationIndicator = this.OwningGrid.ColumnDropLocationIndicator,
                        DragIndicator         = dragIndicator
                    };
                    this.OwningGrid.OnColumnReordering(columnReorderingEventArgs);
                    if (columnReorderingEventArgs.Cancel)
                    {
                        return;
                    }

                    // The user didn't cancel, so prepare for the reorder
                    _dragColumn      = this.OwningColumn;
                    _dragMode        = DragMode.Reorder;
                    _dragStartParent = mousePositionGridParent;
                    // the mouse position relative to the ColumnHeader needs to be scaled to be in the same
                    // dimensions as the DataGrid, so that it doesn't get out of sync later on
                    _dragStart = this.OwningGrid.RenderTransform.Transform(mousePosition);

                    // Display the reordering thumb
                    if (_reorderingThumb == null)
                    {
                        _reorderingThumb = new Popup();
                    }

                    _reorderingThumb.Child  = columnReorderingEventArgs.DragIndicator;
                    _reorderingThumb.IsOpen = true;

                    // use the data template to populate the caret
                    if (columnReorderingEventArgs.DropLocationIndicator != null)
                    {
                        Control child = columnReorderingEventArgs.DropLocationIndicator;

                        this.OwningGrid.ColumnDropLocationIndicatorPopup.Child  = child;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.Height = child.ActualHeight;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.Width  = child.ActualWidth;

                        this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false;
                    }
                }
            }
            #endregion

            #region handle reorder mode (eg, positioning of the popup)
            if (_dragMode == DragMode.Reorder && _reorderingThumb != null)
            {
                DragDeltaEventArgs dragDeltaEventArgs = new DragDeltaEventArgs(mousePositionGrid.X - _lastMousePositionGrid.Value.X, mousePositionGrid.Y - _lastMousePositionGrid.Value.Y);
                this.OwningGrid.OnColumnHeaderDragDelta(dragDeltaEventArgs);

                _reorderingThumb.HorizontalOffset = mousePositionGridParent.X - _dragStart.Value.X;
                _reorderingThumb.VerticalOffset   = _dragStartParent.Value.Y - _dragStart.Value.Y;

                // the mouse position relative to the ColumnHeadersPresenter can be scaled differently than
                // the same position relative to the DataGrid, so apply the grid's RenderTransform
                Point scaledMousePositionHeaders = this.OwningGrid.RenderTransform.Transform(mousePositionHeaders);

                // prepare some variables for clipping/hiding
                double dgX = mousePositionGridParent.X - scaledMousePositionHeaders.X;
                double dgY = mousePositionGridParent.Y - scaledMousePositionHeaders.Y;
                double dgW = this.OwningGrid.CellsWidth;
                double dgH = this.OwningGrid.CellsHeight + this.OwningGrid.ColumnHeaders.ActualHeight;

                // we need to transform the size of the clipping rectangle if the datagrid has a rendertransform set
                Point clipSize = new Point(dgW, dgH);
                clipSize = this.OwningGrid.RenderTransform.Transform(clipSize);

                // clip the thumb to the column headers region
                _reorderingThumb.Child.Clip = new RectangleGeometry
                {
                    Rect = new Rect(
                        dgX - _reorderingThumb.HorizontalOffset,
                        dgY - _reorderingThumb.VerticalOffset,
                        clipSize.X,
                        clipSize.Y
                        )
                };

                // if the datagrid has a scale transform, apply the inverse to the popup's clipping rectangle
                ScaleTransform scaleTransform     = null;
                ScaleTransform gridScaleTransform = _reorderingThumb.Child.RenderTransform as ScaleTransform;
                if (gridScaleTransform != null && gridScaleTransform.ScaleY != 0.0 && gridScaleTransform.ScaleX != 0.0)
                {
                    scaleTransform        = new ScaleTransform();
                    scaleTransform.ScaleX = 1.0 / gridScaleTransform.ScaleX;
                    scaleTransform.ScaleY = 1.0 / gridScaleTransform.ScaleY;
                }
                if (scaleTransform != null)
                {
                    _reorderingThumb.Child.Clip.Transform = scaleTransform;
                }

                // Find header we're hovering over
                DataGridColumn targetColumn = this.GetReorderingTargetColumn(mousePosition, true /* ignoreVertical */, true /* clipToVisible */);

                if (this.OwningGrid.ColumnDropLocationIndicator != null)
                {
                    if (targetColumn == this.OwningGrid.ColumnsInternal.FillerColumn)
                    {
                        // change target column to last column but position caret at the end

                        targetColumn = this.OwningGrid.ColumnsInternal.LastVisibleColumn;

                        Point targetPosition = this.OwningGrid.RenderTransform.Transform(this.Translate(targetColumn.HeaderCell, mousePosition));

                        this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen           = true;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset = mousePositionGridParent.X - targetPosition.X + targetColumn.HeaderCell.ActualWidth;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.VerticalOffset   = mousePositionGridParent.Y - targetPosition.Y;
                    }
                    else if (targetColumn != null)
                    {
                        // try to position caret

                        Point targetPosition = this.OwningGrid.RenderTransform.Transform(this.Translate(targetColumn.HeaderCell, mousePosition));

                        this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen           = true;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset = mousePositionGridParent.X - targetPosition.X;
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.VerticalOffset   = mousePositionGridParent.Y - targetPosition.Y;
                    }
                    else
                    {
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false;
                    }

                    // hide the caret if it's off the grid -- this is not the same as clipping
                    if (this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset < dgX ||
                        dgX + clipSize.X < this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset)
                    {
                        this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false;
                    }
                }

                handled = true;
            }
            #endregion
        }
        private void OnMouseMove_BeginReorder(Point mousePosition)
        {
            DataGridColumnHeader dragIndicator = new DataGridColumnHeader();
            dragIndicator.OwningColumn = this.OwningColumn;
            dragIndicator.IsEnabled = false;
            dragIndicator.Content = this.Content;
            dragIndicator.ContentTemplate = this.ContentTemplate;

            Control dropLocationIndicator = new ContentControl();
            dropLocationIndicator.SetStyleWithType(this.OwningGrid.DropLocationIndicatorStyle);

            if (this.OwningColumn.DragIndicatorStyle != null)
            {
                dragIndicator.SetStyleWithType(this.OwningColumn.DragIndicatorStyle);
            }
            else if (this.OwningGrid.DragIndicatorStyle != null)
            {
                dragIndicator.SetStyleWithType(this.OwningGrid.DragIndicatorStyle);
            }

            // If the user didn't style the dragIndicator's Width, default it to the column header's width
            if (double.IsNaN(dragIndicator.Width))
            {
                dragIndicator.Width = this.ActualWidth;
            }

            // If the user didn't style the dropLocationIndicator's Height, default to the column header's height
            if (double.IsNaN(dropLocationIndicator.Height))
            {
                dropLocationIndicator.Height = this.ActualHeight;
            }

            // pass the caret's data template to the user for modification
            DataGridColumnReorderingEventArgs columnReorderingEventArgs = new DataGridColumnReorderingEventArgs(this.OwningColumn)
            {
                DropLocationIndicator = dropLocationIndicator,
                DragIndicator = dragIndicator
            };
            this.OwningGrid.OnColumnReordering(columnReorderingEventArgs);
            if (columnReorderingEventArgs.Cancel)
            {
                return;
            }

            // The user didn't cancel, so prepare for the reorder
            _dragColumn = this.OwningColumn;
            _dragMode = DragMode.Reorder;
            _dragStart = mousePosition;

            // Display the reordering thumb
            this.OwningGrid.ColumnHeaders.DragColumn = this.OwningColumn;
            this.OwningGrid.ColumnHeaders.DragIndicator = columnReorderingEventArgs.DragIndicator;
            this.OwningGrid.ColumnHeaders.DropLocationIndicator = columnReorderingEventArgs.DropLocationIndicator;
        }