Hello,
Welcome to our Microsoft Q&A platform!
For this function, try adding drag and drop gesture recognizers to the Image
s 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.