private void DestroyViewModel() { if (this.viewModel == null) { return; } this.DataContext = null; this.viewModel.Dispose(); this.viewModel = null; }
private void RefreshViewModel() { if (this.WindowState != GameWindowState.Opened && this.WindowState != GameWindowState.Opening || this.worldObject == null) { return; } if (this.viewModel != null) { if (this.viewModel.WorldObjectFridge == this.worldObject) { // already displaying window for this container return; } this.DestroyViewModel(); } this.viewModel = new ViewModelWindowFridge(this.worldObject, this.privateState, this.Close); this.DataContext = this.viewModel; }