C# 在windows phone 8应用程序中,按住可缩放的按钮,将图像拖动到屏幕上的任意位置
再一次大家好,最近我为WindowsPhone8设备创建了面部变换器应用程序,我设计了一个带有两个图像控件的页面 第一幅图像为背景,第二幅图像控件为前景 我已经在我的第一个图像控件(背景)中添加了“GestureListener”,我必须使用“toolkit:GestureService.GestureListener”来“收缩、放大、缩小、拖动”背景图像 我做的每件事都很好,就像我能成功地捏、缩放、拖动图像一样。。。但是, 问题是“我无法从触摸屏幕上手指的任何位置挤压或拖动图像”。因此,挤压缩放或拖动对我放大/缩小或拖动图像来说非常困难 但在I-Phone/I-pad/I-pod&所有安卓设备中,我都可以通过按压来放大/缩小或拖动屏幕上任何地方的图像 就像我已经说过的,我的第一个图像是背景,可以添加手势控制,第二个图像是普通的图像控制,不能缩放或拖动 这是我的密码 我的XAML代码:C# 在windows phone 8应用程序中,按住可缩放的按钮,将图像拖动到屏幕上的任意位置,c#,wpf,windows-phone-7,windows-phone-8,pinchzoom,C#,Wpf,Windows Phone 7,Windows Phone 8,Pinchzoom,再一次大家好,最近我为WindowsPhone8设备创建了面部变换器应用程序,我设计了一个带有两个图像控件的页面 第一幅图像为背景,第二幅图像控件为前景 我已经在我的第一个图像控件(背景)中添加了“GestureListener”,我必须使用“toolkit:GestureService.GestureListener”来“收缩、放大、缩小、拖动”背景图像 我做的每件事都很好,就像我能成功地捏、缩放、拖动图像一样。。。但是, 问题是“我无法从触摸屏幕上手指的任何位置挤压或拖动图像”。因此,挤压缩
<Grid x:Name="ContentPanel" Grid.RowSpan="2">
<Canvas x:Name="screenArea" Width="400" Height="580" >
<Image x:Name="myImage" Width="400" Height="580" RenderTransformOrigin="0.5, 0.5" CacheMode="BitmapCache" >
<Image.RenderTransform>
<TransformGroup>
<CompositeTransform x:Name="MyMustacheTransformation" />
</TransformGroup>
</Image.RenderTransform>
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener PinchStarted="OnPinchStarted"
PinchDelta="OnPinchDelta"
DragDelta="OnDragDelta"/>
</toolkit:GestureService.GestureListener>
</Image>
<Image x:Name="frameImage" Width="400" Height="580" Stretch="Fill"/>
</Canvas>
</Grid>
我希望你能理解我的要求,如果我的话不清楚,请道歉
如果你已经在Android/i-phone/pod/pad设备上使用了面部变换器应用程序,这意味着他们可以轻松理解我的期望
我的目标是:
“我可以通过捏来放大/缩小、拖动布局上任何地方的图像……就像在i-phone/pod/pad和android设备中一样”
我已经挣扎了几个星期,请给出一些解决方案
我希望你给出的任何示例代码都能对我更有用
提前感谢各位。问题是您将
手势监听器
附加到了图像上,因此只有在触摸图像时才能看到手势
将侦听器连接到最外层的
网格
最终我得到了我所期望的结果。非常感谢所有为我花费宝贵时间的人。谢谢堆栈溢出。,
private void OnPinchStarted(object sender, PinchStartedGestureEventArgs e)
{
_initialAngle = MyMustacheTransformation.Rotation;
_initialScale = MyMustacheTransformation.ScaleX;
}
private void OnPinchDelta(object sender, PinchGestureEventArgs e)
{
MyMustacheTransformation.Rotation = _initialAngle + e.TotalAngleDelta;
MyMustacheTransformation.ScaleX = _initialScale * e.DistanceRatio;
MyMustacheTransformation.ScaleY = _initialScale * e.DistanceRatio;
}
private void OnDragDelta(object sender, DragDeltaGestureEventArgs e)
{
Image rect = sender as Image;
TranslateTransform transform = rect.RenderTransform as TranslateTransform;
MyMustacheTransformation.TranslateX += e.HorizontalChange;
MyMustacheTransformation.TranslateY += e.VerticalChange;
}