Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zoom in and out a ViewBox with mouse scroll and use mouse pointer location as zoom origin

The title is pretty much self-explaining, but to add to the facts, I'm using a large Canvas inside my ViewBox and my ViewBox is placed inside a ScrollViewer. I've set the event handlers for the MouseMove and MouseWheel, and I'm using myViewbox.Width and myViewbox.Height to change the zoom level (which I'm not sure is the proper way). Now I'm stuck on how to set the zoom origin to my mouse pointer location.

Thanks in advance.

like image 574
iXed Avatar asked Nov 13 '22 20:11

iXed


1 Answers

better way is to use the RenderTransform property (particularly ScaleTransform in your case). Have a read here

this could be useful: Pan & Zoom Image

like image 84
Bek Raupov Avatar answered Dec 25 '22 13:12

Bek Raupov