public Document NewDocument(string defaultName, string mimeType, Stream content) { IViewDisplayBinding binding = DisplayBindingService.GetDefaultViewBinding(null, mimeType, null); if (binding == null) { throw new ApplicationException("Can't create display binding for mime type: " + mimeType); } IViewContent newContent = binding.CreateContent(null, mimeType, null); using (content) { newContent.LoadNew(content, mimeType); } if (newContent == null) { throw new ApplicationException(String.Format("Created view content was null{3}DefaultName:{0}{3}MimeType:{1}{3}Content:{2}", defaultName, mimeType, content, Environment.NewLine)); } newContent.UntitledName = defaultName; newContent.IsDirty = true; workbench.ShowView(newContent, true); DisplayBindingService.AttachSubWindows(newContent.WorkbenchWindow); return(WrapDocument(newContent.WorkbenchWindow)); }