protected void OnReordering(ReorderingEventArgs args) { if (this.Reordering != null) { this.Reordering(this, args); } }
private void OnDropInfo(object sender, DragDropEventArgs e) { if (!(e.Options.Source is GridViewRow)) { return; } var gridView = e.Options.Destination as RadGridView; IEnumerable <object> draggedItems = e.Options.Payload as IEnumerable <object>; TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue; this.HideDropPositionFeedbackPresenter(); if (e.Options.Status == DragStatus.DropPossible) { this.UpdateDragCueContent(cue, gridView.Items[gridView.Items.Count - 1], "Move after: "); cue.IsDropPossible = true; } else if (e.Options.Status == DragStatus.DropImpossible) { cue.DragActionContent = null; cue.IsDropPossible = false; } else if (e.Options.Status == DragStatus.DropComplete) { ReorderingEventArgs reorderingArgs = new ReorderingEventArgs(gridView, draggedItems, gridView.Items.Count); this.OnReordering(reorderingArgs); this.TryReorderRows(reorderingArgs); this.OnReordered(new ReorderedEventArgs(gridView, draggedItems)); } e.Handled = true; }
private void TryReorderRows(ReorderingEventArgs args) { IList source = args.SourceGrid.ItemsSource as IList; if (args.Cancel || source == null || source.IsFixedSize) { return; } var newDropIndex = this.RemoveDraggedItems(source, args.DraggedItems, args.DropIndex); this.AddDraggedItems(source, args.DraggedItems, newDropIndex); }
private void OnGridViewRowDropInfo(object sender, DragDropEventArgs e) { this.AssociatedObject.ReleaseMouseCapture(); var senderRow = (GridViewRow)sender; var gridView = senderRow.GridViewDataControl; IEnumerable <object> draggedItems = e.Options.Payload as IEnumerable <object>; TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue; if (e.Options.Status == DragStatus.DropPossible) { var currentRow = this.AssociatedObject.GetContainerFromDataItem((this.currentDropItem)) as GridViewRow; //if(currentRow == null) // cancel drag this.UpdateDragCueContent(cue, currentDropItem, String.Format("Move {0}: ", Enum.GetName(typeof(DropPosition), this.currentDropPosition)).ToLower(CultureInfo.InvariantCulture)); this.ShowDropPositionFeedbackPresenter(gridView, currentRow, this.currentDropPosition); cue.IsDropPossible = true; } else if (e.Options.Status == DragStatus.DropImpossible) { this.HideDropPositionFeedbackPresenter(); this.ClearDragCueContent(cue); cue.IsDropPossible = false; } else if (e.Options.Status == DragStatus.DropComplete) { this.HideDropPositionFeedbackPresenter(); var dropIndex = gridView.Items.IndexOf(this.currentDropItem); if (currentDropPosition == DropPosition.After) { dropIndex++; } ReorderingEventArgs reorderingArgs = new ReorderingEventArgs(gridView, draggedItems, dropIndex); this.OnReordering(reorderingArgs); this.TryReorderRows(reorderingArgs); this.OnReordered(new ReorderedEventArgs(gridView, draggedItems)); } e.Handled = true; }