How to make sure the user can move images to other position

Khos 1 Reputation point
2020-12-28T11:23:05.287+00:00

hi all,

I have a page where the user can upload a bunch of images. When the images are uploaded I want to make sure the user can move the images to change the position of it. Has anyone an idea how I can implement this feature? It would help a lot.

Thanks a lot.
Khos

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JarvanZhang 23,951 Reputation points
    2020-12-28T13:31:47.03+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    For this function, try adding drag and drop gesture recognizers to the Images to change the position. Enable the AllowDrop property and CanDrag property to make the Image can be a drop target and a drag source.

    Check the code:

       <Grid ...>  
           <!--image_1-->  
           <Image Grid.Column="0" HeightRequest="300" WidthRequest="250">  
               <Image.GestureRecognizers>  
                   <DropGestureRecognizer AllowDrop="True"/>  
                   <DragGestureRecognizer CanDrag="True" />  
               </Image.GestureRecognizers>  
           </Image>  
           <!--image_2-->  
           <Image Grid.Column="1" HeightRequest="300" WidthRequest="250">  
               <Image.GestureRecognizers>  
                   <DropGestureRecognizer AllowDrop="True"/>  
                   <DragGestureRecognizer CanDrag="True" />  
               </Image.GestureRecognizers>  
           </Image>  
       </Grid>  
    

    Check the tutorial: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/gestures/drag-and-drop
    Sample code you could refer to: https://learn.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/workingwithgestures-draganddropgesture/

    Best Regards,

    Jarvan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments