Drag and Drop in Windows Phone 7 Mango

How do you implement something like drag and drop using (Silverlight) Windows Phone 7 (Mango)?

That is, I add the image to the center of the page, and then I want the user to be able to move this image around on the screen, possibly also resizing it, pinched.

+4
source share
2 answers

It turned out to be pretty simple as soon as I started playing with Expression Blend 4!

This code really moved well:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <Image Margin="129,112,167,122" Source="mypicture.png" Stretch="Fill"> <Custom:Interaction.Behaviors> <il:MouseDragElementBehavior/> </Custom:Interaction.Behaviors> </Image> </Grid> 

The key part is that in the "Custom: Interaction.Behaviors" section.

Not sure if this can be used to perform some other user operations or pinch, but I think it's not too far?

And this is not only for the Mango Silverlight level - I have not installed the Mango SDK yet, this should work on earlier versions.

  • I found out that this does not seem to allow more than one image to drag out at a time. AFAIK, the iPhone supports 11 fingers, touching the screen right away - I once created an application in which you could move a lot of things on the screen, and it worked well at the same time. Not sure what the limitations are for WP7 phones, but the Samsung I use is probably not limited to just one touch - this is probably the problem with this code. Did someone get a better solution?
+6
source

In Expression Blend 4, go to the tab Asset -> Behavior -> MouseDragElementBehavior to drag an item. To resize pinches, do you mean double click? can you set onMouseLeftButtonUp and set the counter?

0
source

All Articles