Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set up dragging by touch in Windows Universal Apps on Windows 10 Phone?

I have successfully set my Grid up for dragging with a mouse with

<Grid x:Name="SourceGrid13"
              CanDrag="True"
              DragStarting="SourceGrid_DragStarting"
              Margin="0,20,0,0">

However, this is not draggable on a Windows Phone (Windows 10) by touching. How do I set that up?

Also I assume once I get the Grid dragging, the drop sequence will be the same as with a mouse? This is my drop code:

 <ListView HorizontalAlignment="Center" AllowDrop="True"
                 Drop="Image_Drop"
                 DragEnter="TargetImage_DragEnter"
                 DragLeave="TargetImage_DragLeave"
                 CanDragItems="True"
                 IsSwipeEnabled="True"
                 MinHeight="124"
                 Grid.Row="4"
                 Grid.Column="1">
                <Image Height="224"/>
 </ListView>

Also on tablet, it is hard to, but it will drag by touch. Do I need to enable it on the phone somewhere?

I'm now thinking touch drag may be disabled until a future update or the actual release on Windows 10 on Windows Phone.

UPDATE Based on Answers:

I set my listView's CanDragItems and IsSwipeEnabled to True, but this did not change anything. I applied the manipulation rectangle with some strange results. On Phone, I am able to drag the rectangle, but when I bring it into my ListViews, it disappears. Shown by these pictures:

Full Rect:

enter image description here

Dragged it Down out of Framework element- It is dragged behind the listView.

enter image description here

On Desktop, The rectangle is dragged in front of the listView, but after being dragged out of the original Framework Element, it is undraggable.

enter image description here

like image 834
Seth Kitchen Avatar asked Nov 11 '15 19:11

Seth Kitchen


People also ask

How do I enable drag and drop?

Use the Esc Key and Left Click Locate the file or folder you wish to move by left-clicking on it on your desktop. Hit the “Escape” key on your keyboard once. Release the left-click on your mouse. Drag and drop functionality should now work as normal.

How do I drag and drop across Windows?

How do I Drag and Drop? By default, if you left-click and HOLD the left mouse or touchpad button while moving your mouse pointer to a different folder location on the same drive, when you release the left mouse button the file will be moved to the new location where you released the mouse button.


1 Answers

All needed things for any touch screen manipulations are here from the box. There is simple example - Rectangle on the Canvas:

<Canvas Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Rectangle Width="50" Height="50" Fill="Blue" RenderTransformOrigin="0.5,0.5"
        ManipulationDelta="Rectangle_ManipulationDelta" ManipulationMode="All">
        <Rectangle.RenderTransform>
            <TranslateTransform x:Name="dragTranslation" />
        </Rectangle.RenderTransform>
    </Rectangle>
</Canvas>

A minimal handling code is:

private void Rectangle_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e) {
    dragTranslation.X += e.Delta.Translation.X;
    dragTranslation.Y += e.Delta.Translation.Y;
}

It enough to drag any UIElement on Canvas on touch screens AND on desktop with mouse. Dragging of Grid also works.

like image 106
ApceH Hypocrite Avatar answered Sep 19 '22 14:09

ApceH Hypocrite