Hi, I would like to use the ZoomPanel to visualize map but would like to know if there is a functionality whereby I can "pin" a UIElement/Button on the map and have it not scale at all when the ZoomPanel scales? Like on google earth, the label does not scale even the earth zooms in/out...
06-14-2012, 09:08 AM
(This post was last modified: 01-28-2013, 12:00 PM by abenedik.)
You can add a Panel (for example a Canvas) over the ZoomPanel - the content of the Canvas would not be scaled. But you need to adjust the positions of the elements when the zoom panel is changed - subscribe to ViewboxChanged event.
The layout can look like:
<ZoomPanel Name="ZoomPanel1" ...>
<Canvas Name="OverlayCanvas" IsHitTestVisible="false" ...>
On the ViewboxChanged event you can translate the coordinates from your objects inside ZoomPanel with TranslatePoint method:
Point positionInOverlayCanvas = ZoomPanel1.TranslatePoint(positionInZoomPanel, RootPanel)
This will translate the position from the object inside ZoomPanel into position in OverlayCanvas (has the same coodinate system as RootPanel).
EDIT: You need to set IsHitTestVisible on OverlayCanvas to false to prevent it from getting mouse events that should go to ZoomPanel.
I am also looking in to how to achieve this - last time I ended up rescaling the overlay symbols (which were children of my ZoomPanel) whenever the viewbox/zoomfactor changed, but I think this solution is more elegant.
But - as far as I can see the overlay symbols will be stuck when doing panning(move) of the zoomed canvas/image.
Do you have a suggestion to do this?
I do not understand why would the overlay symbols be stuck - the ViewboxChanged event handler is called during panning and zooming so you can update the position and size during panning and zooming.
Could you please provide more information.