Exemple #1
0
        private void PrepareActionContent()
        {
            DragPositionMode dragMode = DragDrop.GetDragPositionMode(this);
            ContentControl   swipeActionContentControl = this.ListView.swipeActionContentControl;

            swipeActionContentControl.DataContext = this.DataContext;

            if (dragMode.HasFlag(DragPositionMode.RailXForward) || dragMode.HasFlag(DragPositionMode.RailXBackwards))
            {
                swipeActionContentControl.Width  = this.ActualWidth;
                swipeActionContentControl.Height = this.ActualHeight;

                Canvas.SetLeft(swipeActionContentControl, 0);
                Canvas.SetTop(swipeActionContentControl, Canvas.GetTop(this));
            }
            else
            {
                swipeActionContentControl.Width  = this.ActualWidth;
                swipeActionContentControl.Height = this.ActualHeight;

                Canvas.SetLeft(swipeActionContentControl, Canvas.GetLeft(this));
                Canvas.SetTop(swipeActionContentControl, 0);
            }

            swipeActionContentControl.Margin = this.Margin;

            swipeActionContentControl.Visibility = Visibility.Visible;

            swipeActionContentControl.Tapped += this.SwipeActionContentControl_Tapped;

            this.ListView.isActionContentDisplayed = true;
        }
        private Point GetRestrictedPosition(Point pointerPosition, DragPositionMode positionRestriction)
        {
            Point result = pointerPosition;

            switch (positionRestriction)
            {
            case DragPositionMode.RailX:
                result = new Point(pointerPosition.X, this.startDragPosition.Y);
                break;

            case DragPositionMode.RailY:
                result = new Point(this.startDragPosition.X, pointerPosition.Y);
                break;

            case DragPositionMode.Free:
            default:
                break;
            }

            return(result);
        }
Exemple #3
0
 public static void SetDragPositionMode(DependencyObject obj, DragPositionMode value)
 {
     obj.SetValue(DragPositionModeProperty, value);
 }
        public DragDropOperation(DragStartingContext startContext, IDragDropElement source, DragPositionMode positionMode, Pointer pointer, Point startClickPosition, Point relativeStartPosition)
        {
            this.sourceElement = source;

            this.dragSurface     = startContext.DragSurface;
            this.dragContext     = new DragContext(startContext.Payload, this);
            this.hitTestStrategy = startContext.HitTestStrategy ?? new DragHitTestStrategy(this.dragSurface.RootElement);

            this.dragVisualContext = this.dragSurface.CreateDragContext();
            this.dragVisualContext.DragStartPosition   = new Point(startClickPosition.X - relativeStartPosition.X, startClickPosition.Y - relativeStartPosition.Y);
            this.dragVisualContext.PositionRestriction = positionMode;

            this.dragVisualContext.PrepareDragVisual(startContext.DragVisual);

            this.startDragPosition     = startClickPosition;
            this.relativeStartPosition = relativeStartPosition;

            this.InitializeVisual();

            this.dragVisualContext.DragVisualHost.PointerMoved       += this.DragVisualHost_PointerMoved;
            this.dragVisualContext.DragVisualHost.PointerReleased    += this.DragVisualHost_PointerReleased;
            this.dragVisualContext.DragVisualHost.PointerCaptureLost += this.DragVisualHost_PointerCaptureLost;

            if (this.dragVisualContext.DragVisualHost.CapturePointer(pointer))
            {
                this.capturedPointer        = pointer;
                this.originalFocusedElement = FocusManager.GetFocusedElement() as Control;
                if (this.originalFocusedElement != null)
                {
                    this.originalFocusState = this.originalFocusedElement.FocusState;
                }
                ((Control)this.dragVisualContext.DragVisualHost).Focus(FocusState.Programmatic);
            }
            else
            {
                this.CancelDrag();
            }

            this.dragSurface.RootElement.KeyDown += this.RootElement_KeyDown;
        }