Pin a UIElement on ZoomPanel so that it doesn't scale?
#1
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...
#2
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:
<Grid Name="RootPanel">
<ZoomPanel Name="ZoomPanel1" ...>
...
</ZoomPanel>
<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.
Andrej Benedik
#3
Hi,

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?

Best regards,

√ėyvind Sannerhaugen
#4
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.
Andrej Benedik
  


Forum Jump:


Users browsing this thread:
1 Guest(s)