Search code examples
xamluwpwindows-10bing-mapsuwp-maps

How can I prevent XAML items from disappearing when their centres leave the map bounds?


I have added XAML elements to my MapControl as according to the official docs.

However when the centre of the item leaves the map bounds it no longer draws, so when zoomed in large items disappear when the centre is no longer visible.

In my case I am drawing a circle of zone of interest around a point, but when you zoom in to street level the centre often leaves the map and the circle vanishes.

How can I ensure the XAML continues to draw when it is still partially on the screen and not just the centre point?


Solution

  • I figured out the particular problem - in my case the XAML item I was attaching was contained at the top level in a Canvas control which had an ActualWidth and ActualHeight of zero. Presumably the clipping happens with the map based on the parent container so negative margins and canvas controls etc. might cause premature vanishing of content.

    I refactored the XAML so the top level was a Grid and wholly contained the child items and the map worked as expected.