StephenShake-9483 avatar image
0 Votes"
StephenShake-9483 asked StephenShake-9483 commented

File/Save for a VSIX custom file editor that hosts a WPF Control

I have been developing a Visual Studio extension to host custom diagrams within projects. The diagrams are developed using WPF user controls and I am now working on implementing the custom editor to host the diagrams. I followed the VSSDK example to implement a WPF designer over an XML file ( and this all works to load the XML into the diagram and properly display the visuals. However, I also need to implement a custom save process with a custom file extension using File/Save and File/Save As. The WPF example has implemented saving the file in the background when idle. When I do a File/Save, the data is not properly saved to XML file through the custom save method and when I do a File/Save As, I am not seeing the custom file extensions in the dialog.

I also reviewed the VSSDK example to implement a WinForms Editor with a Toolbox ( which does demonstrate using File/Save, File/Save As and custom file extensions. It appears that the key to File/Save functionality is in implementing IPersistFileFormat and IVsPersistDocData. The methods for these interfaces also seem to require the Override implementation of WindowPane.Window. The WinForm example for the Window Override simply returns the RichTextBox control as shown below:

 public override IWin32Window Window
         return editorControl;

However in using WPF, doing the same with the WPF user control does not work. I am looking for the bridge between these two examples to utilize IPersistFileFormat and IVsPersistDocData when hosting a WPF user control.

I did try to provide a window wrapper class that would utilize a Diagnostics Process window handle as discussed in this article: But this returned a Default value and failed to work.

To summarize, how can I have the functionality of File/Save for a custom file editor that hosts a WPF control?

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi anonymous user, can you tell me which version of Visual Studio you are using?

0 Votes 0 ·

I am currently using Visual Studio 2019 Enterprise.

0 Votes 0 ·
AnnaXiu-MSFT avatar image AnnaXiu-MSFT StephenShake-9483 ·

Thank you for your feedback. This issue has been escalated for further investigation.

0 Votes 0 ·
Show more comments

Doing a follow up on this thread to see if there is some direction that can be provided to allow a WPF control to tap into the Visual Studio File/Save process to save data to a file. As stated above, this has a sample working for a WinForms solution but there is not any samples or direction on doing this with a WPF control. Would very appreciate an suggestions or samples to address this question.

0 Votes 0 ·

0 Answers