void IDropable.Drop(object data, DropLocation location) { var droppedElement = data as NodeItem; if (droppedElement == null) { return; } if (object.ReferenceEquals(droppedElement, this)) { //if dragged and dropped yourself, don't need to do anything return; } var arg = new NodeDropRequest { DroppedNode = droppedElement.State.DataContext, DropTarget = State.DataContext, Location = location }; var editor = this.FindParentOfType <TreeEditor>(); if (editor.DropCommand != null && editor.DropCommand.CanExecute(arg)) { editor.DropCommand.Execute(arg); } if (location == DropLocation.InPlace) { IsExpanded = true; } }
public void ApplyDrop(NodeDropRequest request) { var droppedNode = new NodeWriteAccess(request.DroppedNode); var dropTarget = new NodeWriteAccess(request.DropTarget); if (request.DropTarget == myRoot) { ChangeParent(droppedNode, n => myRoot.Children.Add(n), myRoot); } else if (request.Location == DropLocation.Before || request.Location == DropLocation.After) { MoveNode(droppedNode, dropTarget, request.Location); } else { ChangeParent(droppedNode, n => dropTarget.Children.Add(n), dropTarget); } }
void IDropable.Drop(object data, DropLocation location) { var droppedElement = data as NodeItem; if (droppedElement == null) { return; } var arg = new NodeDropRequest { DroppedNode = droppedElement.State.DataContext, DropTarget = Root, Location = location }; if (DropCommand != null && DropCommand.CanExecute(arg)) { DropCommand.Execute(arg); } }