private void OnContextDisposing(object sender, EventArgs e) { var context = (EditingContext)sender; Debug.Assert(_context == context, "incorrect context"); if (_selectionContainer != null) { _selectionContainer.Dispose(); _selectionContainer = null; } if (_viewModel != null) { _viewModel.Dispose(); _viewModel = null; } context.Items.SetValue(new MappingDetailsInfo()); context.Disposing -= OnContextDisposing; }