WPF Image Zoom fixed to absolute window position and not relative mouseposition
- The title explains the issue briefly. So I'm making a simple App with WPF where I want to be able to zoom in and out on images. When I zoom in on the first mouse position it does as intended, but if I move the mouse to a different position it is like the program assumes that it is zooming in on the mouse position related to the original unzoomed image, instead of the position on the zoomed image. I.e. I have a Europe map and first step I zoom in on Berlin without moving the mouse, second step, I now want to zoom in on a street in the south western Berlin, but instead the App zooms (pans) down to Spain due to the cursor's position in the original image. I hope it makes sense. I don't think there are issues in the WPF, but I'm missing something in the C# file. Here it is
1 Reply
Point mousePos = e.GetPosition(imagemap);This is probably the problem. I'm going to guess GetPosition doesn't account for the render transform. I'm not sure what the right answer is but I'd either look at translating that point into the render space, or setting the
RenderTransformOrigin