Share via


Defining Custom SharePoint Project Item Types

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:

To enable other developers to use your project item in Visual Studio, create an .spdata file and create an item template or project template that is associated with the project item. For more information, see Creating Item Templates and Project Templates for SharePoint Project Items.

Understanding 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 ISharePointProjectItemTypeProvider.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

Tasks

Walkthrough: Creating a Custom Action Project Item with an Item Template, Part 1

Walkthrough: Creating a Site Column Project Item with a Project Template, Part 1

Walkthrough: Creating a Custom Action Project Item with an Item Template, Part 2

Walkthrough: Creating a Site Column Project Item with a Project Template, Part 2

Concepts

How to: Define a SharePoint Project Item Type

How to: Add a Property to a Custom SharePoint Project Item Type

How to: Add a Shortcut Menu Item to a Custom SharePoint Project Item Type

Creating Item Templates and Project Templates for SharePoint Project Items

Deploying Extensions for the SharePoint Tools in Visual Studio