나는 이것을 위해 조금 더러운 문제를 발견했다. ViewPortChanged 이벤트가 발생하면 MultiScaleImage의 새로 변경된 ViewportOrigin을 아래 메서드로 전달합니다. 문제는 뷰 포트가 비동기 적으로 변경되고 사용자가 실제로 이미지를 경계로 다시 이동하는 것을 볼 수 있다는 것입니다.
public void SetViewportOrigin(Point point)
{
Point bottomRight = ZoomImage.ElementToLogicalPoint(new Point(ZoomImage.ActualWidth/ZoomImage.ViewportWidth - ZoomImage.ActualWidth, ZoomImage.ActualWidth/(ZoomImage.ViewportWidth * 1.33184438 /*ZoomImage.AspectRatio*/) - ZoomImage.ActualHeight));
bottomRight.X -= ZoomImage.ViewportOrigin.X;
bottomRight.Y -= ZoomImage.ViewportOrigin.Y;
if (point.X < 0)
{ //left edge
point.X = 0;
Debug.WriteLine("left edge");
}
else if (point.X > bottomRight.X)
{//right edge
point.X = bottomRight.X;
Debug.WriteLine("right edge");
}
if (point.Y > 1.0)
{//bottom edge
point.Y = 1.0;
Debug.WriteLine("bottom edge1");
}
if (point.Y < 0)
{//top edge
point.Y = 0;
Debug.WriteLine("top edge");
}
else if (point.Y > bottomRight.Y) //bottom edge
{
point.Y = bottomRight.Y;
}
ZoomImage.ViewportOrigin = point;
}