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.
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:
Add a shortcut menu item to the project item. The menu item appears when you open the shortcut menu for the project item in Solution Explorer by right-clicking the project item or by choosing it and then choosing the Shift + F10 keys. For more information, see How to: Add a Shortcut Menu Item to a Custom SharePoint Project Item Type.
Add a custom property to the project item. The property appears in the Properties window when you choose the project item in Solution Explorer. For more information, see How to: Add a Property to a Custom SharePoint Project Item Type.
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.
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.