/// <summary> /// Handler for the ManipulationDelta event. It may or may not be a pinch. If it is not a /// pinch, the ViewportControl will take care of it. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e) { if (e.PinchManipulation != null) { e.Handled = true; if (!_pinching) { _pinching = true; Point center = e.PinchManipulation.Original.Center; _relativeMidpoint = new Point(center.X / TestImage.ActualWidth, center.Y / TestImage.ActualHeight); var xform = TestImage.TransformToVisual(viewport); _screenMidpoint = xform.Transform(center); } _scale = _originalScale * e.PinchManipulation.CumulativeScale; CoerceScale(false); ResizeImage(false); } else if (_pinching) { _pinching = false; _originalScale = _scale = _coercedScale; } }