Provides a WPF Editor when editing XML files that have the '.vstemplate' file extension in Visual Studio.
- Technologies: Visual Studio 2015 SDK
- Topics: Visual Studio Shell
Description
This sample demonstrates how to create an extension with a WPF-based Visual Designer for editing XML files with a specific schema (XSD) in coordination with the Visual Studio XML Editor. In this sample we implement a basic view for .vstemplate files.
Requirements
Get all samples
Clone the repo (How to):
git clone https://github.com/Microsoft/VSSDK-Extensibility-Samples.git
Run the sample
- To run the sample, hitF5 or choose theDebug > Start Debugging menu command. A new experimental instance of Visual Studio will launch.
- Once loaded, press theOpen File button. (Ctrl + O)
- Browse to the TestTemplates sub-directory within the solution and open a file with the '.vstemplate' file extension.
- A new tab opens with the contents of the file laid out in the fields of a WPF form
- Navigate to theView menu and click onCode.
- An additional tab opens with the contents of the file formatted by the XmlEditor
Project Files
- AssemblyInfo.cs
This file contains assembly custom attributes.
- VsTemplateDesignerPackage.cs
Registers the designer, via ProvideXmlEditorChooserDesignerView, as the preferred editor view for files with the .vstemplate extension and indicated schema .
- EditorFactory.cs
Determines if the document to be edited already exists (was already opened in the Xml Editor view), rather than assuming it must be created; creates the designer’s EditorPane as the new Editor.
- EditorPane.cs
Creates the sited designer control and associated XmlModel for the file and text buffer.
- IViewModel.cs
Expresses the interface needed to bind the designer controls to the XmlSchema.
- ViewModel.cs
Implements IViewModel and manages the events needed to synchronize data between the fields in the designer and the underlying XML document, which may also be seen in the XML Editor.
- VsDesignerControl.xaml[.cs]
Implements the WPF controls expressing the designer interface and binds them to the ViewModel.
- VsTemplateSchema.cs
XML schema file generated via xsd.exe vstemplate.xsd /classes /e /n:MyNameSpace.
Related topics