internal static void StartDrag(object sender, HoldingRoutedEventArgs e, DragDropTrigger trigger, object initializeContext = null) { var dragDropElement = sender as IDragDropElement; if (GetRunningOperation(dragDropElement as DependencyObject) != null) { return; } var uiSource = sender as UIElement; var frameworkElementSource = sender as FrameworkElement; double leftMargin = 0d; double topMargin = 0d; if (frameworkElementSource != null) { leftMargin = frameworkElementSource.Margin.Left; topMargin = frameworkElementSource.Margin.Top; } if (dragDropElement == null || !dragDropElement.CanStartDrag(trigger, initializeContext)) { return; } var context = dragDropElement.DragStarting(trigger, initializeContext); var startDragPosition = e.GetPosition(context.DragSurface.RootElement); var relativeStartDragPosition = e.GetPosition(uiSource); relativeStartDragPosition = new Point(relativeStartDragPosition.X + leftMargin, relativeStartDragPosition.Y + topMargin); var dragPositionMode = DragDrop.GetDragPositionMode(uiSource); AddOperation(new DragDropOperation(context, dragDropElement, dragPositionMode, null, startDragPosition, relativeStartDragPosition)); }
DragStartingContext IDragDropElement.DragStarting(DragDropTrigger trigger, object initializeContext) { var dragVisual = this.ParentGrid.DragBehavior.GetReorderVisual(this); if (dragVisual == null) { DataGridFlyoutHeader header = this.CreateHeader(); dragVisual = header; } // TODO: Consider exposing this through separate control. dragVisual.DataContext = this.DataContext; this.Opacity = 0.0; var surface = this.OnDragSurfaceRequested(); var payload = new ReorderItemsDragOperation(this); this.ParentGrid.DragBehavior.OnReorderStarted(this.DataContext as GroupDescriptorBase); return(new DragStartingContext { DragVisual = dragVisual, Payload = payload, DragSurface = surface, HitTestStrategy = new ColumnHeaderHittestStrategy(this, surface.RootElement) }); }
DragStartingContext IDragDropElement.DragStarting(DragDropTrigger trigger, object initializeContext) { this.Opacity = 0; DragStartingContext context = this.CreateDragContext(); this.Owner.DragBehavior.OnDragStarted(this); this.Owner.CancelEdit(); this.Owner.ContentFlyout.Hide(DataGridFlyoutId.All); this.IsSelected = false; return(context); }
bool IDragDropElement.CanStartDrag(DragDropTrigger trigger, object initializeContext) { if (trigger == DragDropTrigger.Hold) { return(this.ListView.IsItemReorderEnabled && this.ListView.GroupDescriptors.Count == 0 && !this.IsHandleEnabled); } else { if (initializeContext == this.reorderHandle && this.reorderHandle != null) { return(this.ListView.IsItemReorderEnabled && this.ListView.GroupDescriptors.Count == 0 && this.IsHandleEnabled); } return(this.ListView.IsActionOnSwipeEnabled && !(this.ListView.ReorderMode == ListViewReorderMode.Handle && this.ListView.IsItemReorderEnabled == true)); } }
internal static void StartDrag(object sender, PointerRoutedEventArgs e, DragDropTrigger trigger, object initializeContext = null) { var dragDropElement = sender as IDragDropElement; var uiSource = sender as UIElement; if (dragDropElement == null) { dragDropElement = ElementTreeHelper.FindVisualAncestor <IDragDropElement>(uiSource); } if (GetRunningOperation(dragDropElement as DependencyObject) != null) { return; } UIElement uiDragDropElement = dragDropElement as UIElement; var frameworkElementSource = dragDropElement as FrameworkElement; double leftMargin = 0d; double topMargin = 0d; if (frameworkElementSource != null) { leftMargin = frameworkElementSource.Margin.Left; topMargin = frameworkElementSource.Margin.Top; } if (dragDropElement == null || !dragDropElement.CanStartDrag(trigger, initializeContext)) { return; } var context = dragDropElement.DragStarting(trigger, initializeContext); if (context == null) { return; } var startDragPosition = e.GetCurrentPoint(context.DragSurface.RootElement).Position; var relativeStartDragPosition = e.GetCurrentPoint(uiDragDropElement).Position; var dragPositionMode = DragDrop.GetDragPositionMode(uiDragDropElement); AddOperation(new DragDropOperation(context, dragDropElement, dragPositionMode, e.Pointer, startDragPosition, relativeStartDragPosition)); }
bool IDragDropElement.CanStartDrag(DragDropTrigger trigger, object initializeContext) { if (trigger == DragDropTrigger.MouseDrag && !this.IsHandleEnabled) { return(this.ListView.IsItemReorderEnabled); } if (trigger == DragDropTrigger.Hold) { return(this.ListView.IsItemReorderEnabled && !this.IsHandleEnabled); } else { if (this.isHandleEnabled && initializeContext == this.reorderHandle) { return(this.ListView.IsItemReorderEnabled && this.IsHandleEnabled); } return(this.ListView.IsActionOnSwipeEnabled && !(this.ListView.ReorderMode == ListViewReorderMode.Handle && this.ListView.IsItemReorderEnabled == true)); } }
bool IDragDropElement.CanStartDrag(DragDropTrigger trigger, object initializeContext) { //// TODO: check CanStartReorder parameter return(this.CanStartDrag(trigger, initializeContext)); }
internal virtual bool CanStartDrag(DragDropTrigger trigger, object initializeContext) { return(false); }
internal void OnItemReorderHandlePressed(RadListViewItem radListViewItem, PointerRoutedEventArgs e, DragDropTrigger trigger, object sender = null) { DragDrop.StartDrag(radListViewItem, e, trigger, sender); }
internal override bool CanStartDrag(DragDropTrigger trigger, object initializeContext) { return(this.Owner.Owner.DragBehavior != null && this.Owner.Owner.DragBehavior.CanStartDragInFlyout(this.DataContext as DataGridColumn)); }
DragStartingContext IDragDropElement.DragStarting(DragDropTrigger trigger, object initializeContext) { return(null); }
bool IDragDropElement.CanStartDrag(DragDropTrigger trigger, object initializeContext) { return(false); }
DragStartingContext IDragDropElement.DragStarting(DragDropTrigger trigger, object initializeContext) { this.ListView.CleanupSwipedItem(); DragStartingContext context = null; var dataItem = this.DataContext; if (dataItem != null) { bool isExecuted = false; DragAction?dragAction = null; if (trigger == DragDropTrigger.Drag && initializeContext != this.reorderHandle) { if (this.ListView.LayoutDefinition is StackLayoutDefinition) { if (this.Owner.Orientation == Orientation.Horizontal) { if (this.SwipeDirection == ListViewItemSwipeDirection.Forward) { DragDrop.SetDragPositionMode(this, DragPositionMode.RailYForward); } else if (this.SwipeDirection == ListViewItemSwipeDirection.Backwards) { DragDrop.SetDragPositionMode(this, DragPositionMode.RailYBackwards); } else if (this.SwipeDirection == ListViewItemSwipeDirection.All) { DragDrop.SetDragPositionMode(this, DragPositionMode.RailY); } } else { if (this.SwipeDirection == ListViewItemSwipeDirection.Forward) { DragDrop.SetDragPositionMode(this, DragPositionMode.RailXForward); } else if (this.SwipeDirection == ListViewItemSwipeDirection.Backwards) { DragDrop.SetDragPositionMode(this, DragPositionMode.RailXBackwards); } else if (this.SwipeDirection == ListViewItemSwipeDirection.All) { DragDrop.SetDragPositionMode(this, DragPositionMode.RailX); } } isExecuted = this.ListView.commandService.ExecuteCommand(CommandId.ItemDragStarting, new ItemDragStartingContext(dataItem, DragAction.ItemAction, this)); dragAction = DragAction.ItemAction; this.PrepareDragVisual(dragAction.Value); } } else { isExecuted = this.ListView.commandService.ExecuteCommand(CommandId.ItemDragStarting, new ItemDragStartingContext(dataItem, DragAction.Reorder, this)); dragAction = DragAction.Reorder; this.PrepareDragVisual(dragAction.Value); } if (isExecuted && dragAction.HasValue) { this.CancelDirectManipulations(); if (dragAction.Value == DragAction.Reorder) { context = this.InitializeReorder(); } else if (dragAction.Value == DragAction.ItemAction) { // We might need to cancel manipulations on the dragvisual //// this.dragVisual.CancelDirectManipulations(); this.UpdateActionContentClipping(0); context = new DragStartingContext { DragSurface = new CanvasDragSurface(this.ListView.childrenPanel, this.ListView.childrenPanel as Canvas, false), DragVisual = this.dragVisual, HitTestStrategy = new ListViewItemHittestStrategy(this, this), Payload = DragAction.ItemAction }; } } } return(context); }
internal override bool CanStartDrag(DragDropTrigger trigger, object initializeContext = null) { return(this.ParentGrid.DragBehavior != null && this.ParentGrid.DragBehavior.CanStartReorder(this.DataContext as GroupDescriptorBase)); }
bool IDragDropElement.CanStartDrag(DragDropTrigger trigger, object initializeContext) { return(this.Owner.DragBehavior != null && this.Owner.DragBehavior.CanStartDrag(this.Column)); }
DragStartingContext IDragDropElement.DragStarting(DragDropTrigger trigger, object initializeContext) { throw new NotImplementedException(); }