我有一个 Windows Phone Silverlight 8.1 应用程序。我想要缩放图像。这是我的代码片段。问题在于它不会在捏的地方进行缩放。它总是在图像的左上角进行缩放。任何帮助将不胜感激。谢谢。
private void Image_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
if (e.PinchManipulation != null)
{
var transform = (CompositeTransform)img.RenderTransform;
// Scale Manipulation
transform.ScaleX = e.PinchManipulation.CumulativeScale;
transform.ScaleY = e.PinchManipulation.CumulativeScale;
// Translate manipulation
var originalCenter = e.PinchManipulation.Original.Center;
var newCenter = e.PinchManipulation.Current.Center;
transform.TranslateX = newCenter.X - originalCenter.X;
transform.TranslateY = newCenter.Y - originalCenter.Y;
e.Handled = true;
}
}