提前致谢..
在我的 WP7 应用程序中,我使用了以下代码来缩放图像。
<Image Name="imgThumbnail" Width="480" Height="740" VerticalAlignment="Center" HorizontalAlignment="Center" RenderTransformOrigin="0.5, 0.5" CacheMode="BitmapCache">
<Image.RenderTransform>
<CompositeTransform x:Name="transform" />
</Image.RenderTransform>
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener PinchDelta="OnPinchDelta" PinchStarted="OnPinchStarted" />
</toolkit:GestureService.GestureListener>
</Image>
private void OnPinchStarted(object sender, PinchStartedGestureEventArgs e)
{
var image = sender as System.Windows.Controls.Image;
if (image == null) return;
var transform = image.RenderTransform as CompositeTransform;
if (transform == null) return;
initialScale = transform.ScaleX;
}
private void OnPinchDelta(object sender, PinchGestureEventArgs e)
{
var image = sender as System.Windows.Controls.Image;
if (image == null) return;
var transform = image.RenderTransform as CompositeTransform;
if (transform == null) return;
transform.ScaleX = initialScale * e.DistanceRatio;
transform.ScaleY = initialScale * e.DistanceRatio;
}
缩放工作正常,但我无法滚动图像。添加滚动查看器时,缩放不起作用。有什么问题,我该如何解决这个问题?