How can you calculate the X/Y coordinate to zoom to
Posted
by Mark
on Stack Overflow
See other posts from Stack Overflow
or by Mark
Published on 2010-03-03T21:58:43Z
Indexed on
2010/03/09
3:06 UTC
Read the original article
Hit count: 350
Im writing a WPF application that has a zoom and pan ability, but what I want to also implement is the ability to zoom and pan "automatically" (via a button click).
I have the methods all defined to zoom and pan, but Im having trouble telling the app the desired X/Y coordinates for the panning.
Basically, I know that I want the control to be centered at a desired zoom level (say zoomed in 6X times), but the panning destination point is NOT the center point of the control because after the zooming, its been scaled.
Does anyone know a way of calculating the desired X/Y position to pan to, taking into account the zooming as well? Do I just scale the desired destination Point? It doesnt seem to work for me...
Thanks a lot
© Stack Overflow or respective owner