Drag and drop Image UserControl in a Metro App?
-
2012年3月7日 上午 07:44
Hi,
I have an image control in a xaml file:
<Image x:Name="myImage" />
I need to be able to drag the image around in my view at runtime. How do I go about doing this?
Thanks much.
V
所有回覆
-
2012年3月7日 上午 10:40
<Image x:Name="myImage" Source="Assets/Logo.png" Stretch="None" HorizontalAlignment="Center" VerticalAlignment="Center" ManipulationMode="All" ManipulationDelta="myImage_ManipulationDelta_1"> <Image.RenderTransform> <CompositeTransform /> </Image.RenderTransform> </Image>and the event handler
private void myImage_ManipulationDelta_1(object sender, ManipulationDeltaRoutedEventArgs e) { var ct = (CompositeTransform)myImage.RenderTransform; ct.TranslateX += e.Delta.Translation.X; ct.TranslateY += e.Delta.Translation.Y; }- 已提議為解答 Matt SmallMicrosoft Employee, Moderator 2012年3月8日 下午 04:40
- 已標示為解答 Min ZhuMicrosoft Contingent Staff, Moderator 2012年3月12日 上午 03:08
-
2012年5月19日 上午 09:39
Hi,
How Can i get drag and drop released (finished) event ? in order to callback
Grant
- 已編輯 Tsingbegin 2012年5月19日 上午 09:42
-
2012年5月19日 下午 07:00
For XAML in Windows 8 the Drag and drop related events only fire when you start a Drag action from a ListView or GridView. If you are just performing your own drag such as you are doing, you will have to rely on listening to pointer events to determine when the drag is "done".
thanks,
-mark
Program Manager
Microsoft
This post is provided "as-is"- 已提議為解答 Mark RideoutMicrosoft Employee 2012年5月19日 下午 07:00
-
2012年7月22日 下午 06:54
-
2013年4月17日 上午 10:09Thanks for the code , is there a way to test whether the picture that we're moving is in a specific place or not please

