在 Silverlight/WP7 应用程序中使用 MultiTouchBehavior 时,如何以编程方式查找缩放、旋转和平移值?
好吧,这似乎是一个非常愚蠢的问题,但我还不太习惯 Silverlight 领域。我正在开发一个引用 Multitouch.Behaviors.WP7 codeplex 项目的 Silverlight / WP7 应用程序 (http://multitouch.codeplex .com/)。
<Canvas x:Name="MyCanvas">
<Image Source="Images/image.png"
x:Name="MyImage" Width="120"
Canvas.Left="240" Canvas.Top="235">
<i:Interaction.Behaviors>
<tb:MultiTouchBehavior
AreFingersVisible="True"
IsDebugModeActive="True"
IsMockActive="True"
IsRotateEnabled="True"
IsScaleEnabled="True"
IsTranslateXEnabled="True"
IsTranslateYEnabled="True"
MaximumScale="100"
MinimumScale="0.5"/>
</i:Interaction.Behaviors>
</Image>
显然,用户可以使用多点触控功能拖动图像、旋转图像并缩放图像。如何以编程方式访问图像缩放/旋转/平移的值?
Okay, this may seem like a really silly question but I'm not quite used to the Silverlight realm yet. I'm working on a Silverlight / WP7 application that references the Multitouch.Behaviors.WP7 codeplex project (http://multitouch.codeplex.com/).
<Canvas x:Name="MyCanvas">
<Image Source="Images/image.png"
x:Name="MyImage" Width="120"
Canvas.Left="240" Canvas.Top="235">
<i:Interaction.Behaviors>
<tb:MultiTouchBehavior
AreFingersVisible="True"
IsDebugModeActive="True"
IsMockActive="True"
IsRotateEnabled="True"
IsScaleEnabled="True"
IsTranslateXEnabled="True"
IsTranslateYEnabled="True"
MaximumScale="100"
MinimumScale="0.5"/>
</i:Interaction.Behaviors>
</Image>
Obviously, the user can drag the image around, rotate it, and scale it with the multitouch functionality. How can I access the values for how the image has been scaled/rotated/translated programatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MultitouchBehavior 使用 CompositeTransform 作为 RenderTransform对于与其关联的对象。因此,您可以使用类似于以下的代码来访问转换后的值:
The MultitouchBehavior uses a CompositeTransform as the RenderTransform for the object that it is associated with. So, you can use code similar to the following to access the transformed values:
您需要使用 Image.RenderTransform。
请参阅这篇文章(特别是 GestureHelper 部分 - http://timheuer.com/blog/archive/2010/09/16/silverlight-toolkit-for-windows-phone-7-released.aspx)。
然后使用 DistanceRatio 获取平移值:
You need to use Image.RenderTransform.
See this post (particularly the GestureHelper section - http://timheuer.com/blog/archive/2010/09/16/silverlight-toolkit-for-windows-phone-7-released.aspx).
And then use DistanceRatio to get the value for translation: