Share via


Define custom SharePoint project item types

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Define a new SharePoint project item type when you want to create a new kind of SharePoint project item. For example, Visual Studio does not include SharePoint project items for adding fields or custom actions to a SharePoint site. You can define your own types of SharePoint project items for creating fields, custom actions, or other types of SharePoint components.

Tasks for defining SharePoint project item types

To define a custom project item type, build a Visual Studio extension assembly that implements the ISharePointProjectItemTypeProvider interface. For more information, see How to: Define a SharePoint project item type.

When you define a custom project item type, you can also add the following functionality to the project item:

Understand the relationship between project item types and project item instances

When you define a SharePoint project item type, Visual Studio loads your extension when a project item of the associated type is added to a SharePoint project. For example, if you define a new Custom Action project item type, Visual Studio loads your extension when a user adds a Custom Action project item to a project. Visual Studio uses the same instance of your extension for all instances of the associated project item type. In the previous example, if the user adds a second Custom Action project item to the project, the same instance of your extension is used to customize the second project item.

To access a specific instance of your project item type, handle one of the ISharePointProjectItemEvents events of the projectItemTypeDefinition parameter in your implementation of the InitializeType method. For example, to determine when a project item of your custom type is added to a project, handle the ProjectItemAdded event. For more information, see How to: Define a SharePoint project item type.

See also