How to handle a map redraw

Topics: Help, WPF
Mar 13 at 4:31 PM
Edited Mar 13 at 4:37 PM

in my WPF application I have a map on a Tab:


When I move to the other tab and back to the map, all markers disappear and, if I add a new one it is not displayed.
The code where I handle the makers is:
    private void Vm_OnNewMarkerChanged(GMap.NET.WindowsPresentation.GMapMarker Marker)
      var idx = MainMap.Markers.IndexOf(Marker);

      if (idx >= 0)
        MainMap.Markers[idx] = Marker;
MainMap is:
  class Map : GMapControl
and in the Window.xaml:
<local:Map x:Name="MainMap" Grid.Column="1" Zoom="13" MaxZoom="24" MinZoom="1" />
public MainWindow(MainVM viewModel)
    _ViewModel = viewModel;
    _ViewModel.OnNewMarkerChanged += Vm_OnNewMarkerChanged;

    DataContext = _ViewModel;


    GMaps.Instance.UseRouteCache = true;
    GMaps.Instance.UseGeocoderCache = true;
    GMaps.Instance.Mode = AccessMode.ServerAndCache;

    MainMap.MapProvider = GMapProviders.OpenStreetMap;
    MainMap.CacheLocation = System.AppDomain.CurrentDomain.BaseDirectory;
    MainMap.ShowTileGridLines = false;
    MainMap.Manager.Mode = AccessMode.ServerAndCache;
    MainMap.DragButton = System.Windows.Input.MouseButton.Left;

    MainMap.MouseMove += new System.Windows.Input.MouseEventHandler(MainMap_MouseMove);
    MainMap.OnMapZoomChanged += MainMap_OnMapZoomChanged;
I have to handle the map refresh in some particular way?
Mar 13 at 6:21 PM
The problem was in my code: on unloading the marker the icon was destroyed and no more recreated.

Sorry for the junk question. :)
Marked as answer by DBarzo on 3/13/2017 at 10:21 AM