void SwapElement(double x, double y) { int index = GetIndexFromPoint(x, y); if (index == _draggedIndex || index < 0) { return; } if (index >= Children.Count) { index = Children.Count - 1; } int[] parameter = new int[] { _draggedIndex, index }; if (SwapCommand != null && SwapCommand.CanExecute(parameter)) { SwapCommand.Execute(parameter); _draggedElement = Children[index]; //this is bcause after changing the collection the element is other FillNewDraggedChild(_draggedElement); _draggedIndex = index; } this.InvalidateArrange(); }