wieslawsoltes / PanAndZoom

Pan and zoom control for Avalonia.
http://wieslawsoltes.github.io/PanAndZoom/
MIT License
345 stars 45 forks source link

ZoomBorder inside TabControl (WPF) #20

Closed Crewman123 closed 4 years ago

Crewman123 commented 6 years ago

TabControl in WPF is a bit special it loads and unloads the content of its TabControl Items each time a tab is shown or hidden.

This causes the PanAndZoom_Loaded and PanAndZoom_Unloaded eventHandlers to be called multiple times.

This results in the following behavior: If I switch the tab in the TabControl, zoom and offset of the ZoomBorder Control is always reset to default. I am not sure if this is the intended behavior. If so it would be nice to have an option(boolean property) to not reset to default zoom and offsets.

teajaysee commented 4 years ago

I got the same thing, I've never seen this on a wpf control before, so maybe the code in the Loaded event should be elsewhere. It's easy to workaround by saving the x,y and ratio values in UnLoaded and setting them again on Loaded. Apart from that, excellent control, thank you very much!!! It would be great to add 'Rotate' too - I have done this manually using a Render Transform on the ZoomBorder and works fine, though ideally it should work on the Canvas inside the ZoomBorder, not the ZoomBorder itself. Thanks again.