public void Dispose() { if (isDisposed) { return; } documentViewerControl.TextView.VisualElement.Loaded -= VisualElement_Loaded; Removed?.Invoke(this, new DocumentViewerRemovedEventArgs(this)); documentViewerServiceImpl.RaiseRemovedEvent(this); wpfCommandService.Remove(ControlConstants.GUID_DOCUMENTVIEWER_UICONTEXT, documentViewerControl); documentViewerControl.Dispose(); outputData.Clear(); isDisposed = true; }