Share via


Extending SharePoint Project Items

Create a project item extension when you want to add functionality to a type of SharePoint project item that is already installed in Visual Studio. For example, you can create an extension for the built-in Event Receiver or List Definition project items in Visual Studio, or you can create an extension for a custom project item type. You can also create an extension for all types of SharePoint project items.

Tasks for Extending SharePoint Project Items

To extend a project item, build a Visual Studio extension assembly that implements the ISharePointProjectItemTypeExtension interface. For more information, see How to: Create a SharePoint Project Item Extension.

When you extend a project item, you can also add the following functionality to the project item:

For a walkthrough that demonstrates how to create, deploy, and test a project item extension, see Walkthrough: Extending a SharePoint Project Item Type.

Understanding the Relationship Between Project Item Extensions and Project Item Instances

When you create a project item extension, Visual Studio loads your extension when a project item of the associated type is added to a SharePoint project. For example, if you create an extension for Event Receiver project items, Visual Studio loads your extension when a user adds an Event Receiver 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 Event Receiver 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 the project item type you are extending, handle one of the ISharePointProjectItemEvents events of the projectItemType parameter in your implementation of the ISharePointProjectItemTypeExtension.Initialize method. For example, to determine when a project item of the type you are extending is added to a project, handle the ProjectItemAdded event. For more information, see How to: Create a SharePoint Project Item Extension.

Identifiers for SharePoint Project Items

Each SharePoint project item has a corresponding string identifier. You must know the identifier for a project item if you want to perform the following tasks:

  • Create an extension for the project item. In this case, you must pass the identifier for the project item that you want to extend to the constructor of the SharePointProjectItemTypeAttribute. To create an extension for all project item types, pass the * string value.

  • Add the project item to a project programmatically. In this case, you must pass the identifier for the project item to the ISharePointProjectItemCollection.Add method.

The following table lists the identifiers for the SharePoint project items that are included with Visual Studio 2010.

Project item name

String identifier

Business Data Catalog Model

Microsoft.VisualStudio.SharePoint.BusinessDataConnectivity

Content Type

Microsoft.VisualStudio.SharePoint.ContentType

Event Receiver

Microsoft.VisualStudio.SharePoint.EventHandler

Empty Element

Microsoft.VisualStudio.SharePoint.GenericElement

List Definition

List Definition From Content Type

Microsoft.VisualStudio.SharePoint.ListDefinition

List Instance

Microsoft.VisualStudio.SharePoint.ListInstance

Module

Microsoft.VisualStudio.SharePoint.Module

Sequential Workflow

State Machine Workflow

Microsoft.VisualStudio.SharePoint.Workflow

Site Definition

Microsoft.VisualStudio.SharePoint.SiteDefinition

Visual Web Part

Microsoft.VisualStudio.SharePoint.VisualWebPart

Web Part

Microsoft.VisualStudio.SharePoint.WebPart

Workflow Association Form

Microsoft.VisualStudio.SharePoint.WorkflowAssociation

See Also

Tasks

Walkthrough: Extending a SharePoint Project Item Type

Concepts

How to: Create a SharePoint Project Item Extension

How to: Add a Shortcut Menu Item to a SharePoint Project Item Extension

How to: Add a Property to a SharePoint Project Item Extension

Extending the SharePoint Project System