private void dataGridSheet_MouseDown(object sender, MouseButtonEventArgs e) { try { //collect drag source copyInfo = new CellCopyInfo(); DataGridCell cell = DataGridUtils.FindVisualParent <DataGridCell>(e.OriginalSource as UIElement); if (e.RightButton == MouseButtonState.Pressed && null != cell) { DataGridUtils.FindDragSource(dataGridSheet, dataGridSheet.SelectedCells, ref copyInfo); DataObject dataObject = new DataObject(copyInfo); tempDragRows = new List <int>(); DragDrop.DoDragDrop(cell, dataObject, DragDropEffects.Copy); } } catch (Exception ex) { string message = ex.Message; } }
private void dataGridSheet_PreviewDrop(object sender, DragEventArgs e) { try { //copy elements if (e.AllowedEffects == DragDropEffects.Copy) { if (copyInfo.RowSourceStartIndex != -1 && copyInfo.ColumnSourceStartIndex != -1) { bool copied = DataGridUtils.CopyRowItems(dataGridSheet, copyInfo); } } copyInfo = new CellCopyInfo(); DataGridUtils.PaintDragCells(dataGridSheet, copyInfo, false); } catch (Exception ex) { string message = ex.Message; } }