//

        #endregion

        #region Drag Source Events
        // DragSource

        private void DragSource_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this._sourceItemsControl = (ItemsControl)sender;
            var visual = e.OriginalSource as Visual;

            this._sourceDataContext = (sender as DataGrid).DataContext;
            this._targetDataContext = null;

            this._mappedValueCollection = AttachedColumnBehavior.GetMappedValues(sender as DependencyObject);

            this._topWindow            = Window.GetWindow(this._sourceItemsControl);
            this._initialMousePosition = e.GetPosition(this._topWindow);

            this._sourceItemContainer = _sourceItemsControl.ContainerFromElement(visual) as FrameworkElement;

            _columnsModel = GetColumnModel(sender, e, out _sourceCell);

            if (_columnsModel == null)
            {
                return;
            }

            if (this._sourceItemContainer != null)
            {
                _rowModel         = this._sourceItemContainer.DataContext;
                this._draggedData = AttachedColumnBehavior.GetMappedValues(sender as DependencyObject).ReturnIfExistAddIfNot(_columnsModel, _rowModel);
            }
        }
        private void DragSource_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            IList <DataGridCellInfo> selectedCells = (sender as DataGrid).SelectedCells;

            this._multipleDraggedData.Clear();

            selectedCells.ToList().ForEach(x =>
            {
                RowViewModel rowModel        = x.Item as RowViewModel;
                ColumnsViewModel columnModel = x.Column.Header as ColumnsViewModel;
                MappedValue value            = AttachedColumnBehavior.GetMappedValues(sender as DependencyObject).ReturnIfExistAddIfNot(columnModel, rowModel);

                var selectedCell = rowModel.Name + columnModel.Currency;

                if (value.Value != null && selectedCells.Count > 1 && !_multipleDraggedData.ContainsKey(selectedCell))
                {
                    this._multipleDraggedData.Add(selectedCell, value);
                }
            });

            _isMultipleCells = selectedCells.Count > 1;
        }
        private void DropTarget_PreviewDrop(object sender, DragEventArgs e)
        {
            object draggedItem = e.Data.GetData(this._format.Name);

            int indexRemoved = -1;

            if (draggedItem != null)
            {
                if ((e.Effects & DragDropEffects.Move) != 0 && (this._sourceItemsControl == this._targetItemsControl || GetIsDropRejectFromOthers(this._targetItemsControl)))
                {
                    this._targetDataContext = (sender as DataGrid).DataContext;

                    // Remove the selected Cell here from Mapped Values
                    DataGrid dgc = sender as DataGrid;

                    RowViewModel     sourceRowHeader    = ((RowViewModel)(dgc.CurrentItem));
                    ColumnsViewModel sourceColumnHeader = ((ColumnsViewModel)((dgc.CurrentColumn).Header));
                    string           srcCell            = sourceRowHeader.Name + sourceColumnHeader.Currency;


                    MappedValueCollection sourceCell  = AttachedColumnBehavior.GetMappedValues(sender as DependencyObject);
                    MappedValue           mappedValue = sourceCell.ReturnIfExistAddIfNot(sourceColumnHeader, sourceRowHeader);
                    int getIndex = sourceCell.IndexOf(mappedValue);

                    //var hitTestInfo = (sender as DataGrid).InputHitTest(new Point{ X = e.})

                    sourceCell[getIndex].Value = (draggedItem as MappedValue).Value;


                    //indexRemoved = RemoveItemFromItemsControl(this._sourceItemsControl, draggedItem);
                }
                // This happens when we drag an item to a later position within the same ItemsControl.
                if (indexRemoved != -1 && this._sourceItemsControl == this._targetItemsControl && indexRemoved < this._insertionIndex)
                {
                    this._insertionIndex--;
                }
                if (!GetIsDropRejectFromOthers(this._targetItemsControl))
                {
                    IEnumerable itemsSource      = _targetItemsControl.ItemsSource;
                    Type        type             = itemsSource.GetType();
                    Type        genericIListType = type.GetInterface("IList`1");
                    int         elementsCount    = 0;
                    if (genericIListType != null)
                    {
                        elementsCount = (int)type.GetProperty("Count").GetValue(itemsSource, null);
                    }
                    if (elementsCount > this._insertionIndex)
                    {
                        RemoveItemFromItemsControlByIndex(this._targetItemsControl, this._insertionIndex);
                        InsertItemInItemsControl(this._targetItemsControl, draggedItem, this._insertionIndex);

                        if (this._sourceItemsControl == this._targetItemsControl)
                        {
                            Type   draggedType = draggedItem.GetType();
                            object newitem     = Activator.CreateInstance(draggedType);
                            InsertItemInItemsControl(this._sourceItemsControl, newitem, indexRemoved);
                        }
                    }
                }
                else
                {
                    Type   draggedType = draggedItem.GetType();
                    object newitem     = Activator.CreateInstance(draggedType);
                    //InsertItemInItemsControl(this._sourceItemsControl, newitem, indexRemoved);
                }

                RemoveDraggedAdorner();
                RemoveInsertionAdorner();
            }
            e.Handled = true;
        }