0

I have different XAML Line Controls defined inside a MapControl. They change the rotation, color, ... so I thought it was better to do with lines that with MapPolyline which are supposed to stay static.

When panning around the map I found that when the origin of the lines are out of the MapControl, sometimes the lines dissappear, sometimes not. They dissappear only when outside the MapControl BUT on the right side or the lower side. THat doesn't happen when they pan out left side or upper side.

Obviously, I want them in the screen everytime, I don't want to dissappear them.

Any idea why it happens? And how can I get them visible all the time?

Lines visible when origin (orange point) inside the MapControl

Lines visible when origin (orange point) inside the MapControl Lines hidden when Lines origin outside right side Lines hidden when Lines origin outside right side. Orange point is partially visible.

Lines visible when origin outside left side Lines visible when origin outside left side. Even the orange point is outside the control, but lines are still visible.

2 Answers2

1

It appears there is some code that toggles the visibility of attached XAML items based on whether the attached points are in the viewport. You could work around this by introducing additional points along the line. In general, It's recommended to use MapElements rather than attached XAML for most scenarios. XAML should really only be used for things like dialogs with rich UI where you have relatively few such objects attached to the map. MapPolyline will perform better even for scenarios where you want to update the properties and position and will stay in sync with map motion much better than XAML.

Duncan Lawler
  • 1,772
  • 8
  • 13
  • I know time has passed since you wrote an answer, but I forgot to tell how it worked following your guidelines. If the XAML line is replaced by a MapElement with MapPolyline, 1-. line doesn't disappears when origin boundaries are not in the screen. 2-. Line appears aliased, and it's not elegant to have such sawteeth. 3-. To change MapPolyline starting point and ending point is more slugish that doing with XAML lines, the movement is not smooth. Actually, you can see how it's drawn... – Imanol Zubiaurre Jun 08 '19 at 14:34
0

I have found a solution for the dissapearing lines problem.

All the lines and XAML shapes that were just on the MapControl should be grouped inside a canvas, width the correct width and height (in my case the max length of the lines in both dimensions and also negative and positive directions, center/anchor the canvas in the MapControl.Center and play with margins tofit all the controls correctly).

For all the tests I have done, lines stays in th screen even both starting point and the ending point are not in the screen.