public static MapLayersWindow GetInstance()
 {
     if (_instance == null)
     {
         _instance = new MapLayersWindow();
     }
     return(_instance);
 }
        private void Cleanup()
        {
            if (MapWindowManager.MapLayersHandler != null)
            {
                MapWindowManager.MapLayersViewModel.LayerRead    -= MapLayersViewModel_LayerRead;
                MapWindowManager.MapLayersViewModel.LayerRemoved -= MapLayersViewModel_LayerRemoved;
                MapWindowManager.MapLayersViewModel.CurrentLayer -= MapLayersViewModel_CurrentLayer;
            }

            dataGridLayers.SelectionChanged   -= DataGridLayers_SelectionChanged;
            dataGridLayers.DataContextChanged -= DataGridLayers_DataContextChanged;
            dataGridLayers.PreviewDrop        -= DataGridLayers_PreviewDrop;
            dataGridLayers.PreviewMouseDown   -= DataGridLayers_PreviewMouseDown;
            dataGridLayers.LayoutUpdated      -= DataGridLayers_LayoutUpdated;

            ParentForm.Closing -= ParentForm_Closing;

            MapLayersHandler.OnLayerVisibilityChanged -= MapLayersHandler_OnLayerVisibilityChanged;

            _instance = null;
            MapWindowManager.MapLayersWindow = null;
            this.SavePlacement();
        }
 private void OnWindowClosed(object sender, EventArgs e)
 {
     _instance = null;
 }