Extending Visual Studio 2010 for SharePoint 2010

With Visual Studio 2010, developers across the world are discovering that they have SharePoint development tools out of the box.

Steve Fox

May 25, 2010

3 Min Read
ITPro Today logo

In the wake of the Visual Studio (VS) 2010 launch, developers across the world are discovering that they have SharePoint development tools out of the box. For those of you who haven’t tested this functionality, many VS project- and item-level templates cut across the most commonly programmed artifacts in SharePoint, such as Web Parts, event receivers, list definitions, workflow, and content types, among many others. All of these come with an F5 debug experience that works exactly as we all expect.

However, what devs might not see out of the gate is what’s really exciting: the ability to customize and extend VS 2010 to add even more SharePoint developer features.

The reason this is exciting is twofold: VS 2010 provides an extensibility model that enables you to a) not only develop into the object model for Visual Studio to create project or deployment extensions, but b) combine that with the SharePoint object model.

What this offers is the ability to extend what Microsoft has provided out of the box to augment the SharePoint experience. Given the strong SharePoint developer community, you will assuredly see some compelling extensibilities making their way into the market.

The trend to extend VS 2010 for SharePoint development is already underway. For example, if you visit the CodePlex page “SharePoint Developer Tools for Visual Studio 2010” (sharepointdevtools.codeplex.com) you’ll see three community projects that were posted just after the SharePoint Beta release. These projects cover sandboxed Visual Web Parts, SP Metal integration (SP Metal is a utility to generate an entity model for your SharePoint lists), and advanced deployment. Each of these projects offers both VS extensibility and feature augmentations for the SharePoint development experience.

More examples of extensibility community projects are the just-released SharePoint 2010 extensibility projects on the MSDN Code Gallery website (code.msdn.microsoft.com/vsixforsp). Included with these templates are templates for Microsoft Silverlight and SharePoint Web Parts, SharePoint ribbon extensibility, and an Office Business Application deployment template—all augmentations to the current SharePoint experience.

After you download the templates, you install by double-clicking the VSIX files, after which you can see the extensibility templates exposed in the VS Extension Manager (shown in Figure 1). Here, you can disable or uninstall the VS extensibility templates.

Let’s take a closer look at one of these templates to give you an idea of what it entails. In the latest release of the extensibility templates, the Silverlight Web Part template is an interesting project-level template that integrates the dynamic and rich nature of Silverlight development with the power of SharePoint.

The Silverlight Web Part extensibility is a project-level template that enables you to create Silverlight Web Parts for SharePoint—leveraging the core tooling already available in VS 2010.

When you click File, New and Project, you can select the new Silverlight Web Part project template as one of your options. A wizard prompts you for information (SharePoint site, Silverlight application name, and Web Part name and description).

Using this template, you create a project that has a Silverlight application and a SharePoint Web Part combined within one project structure. Default sample code lets you uncomment and deploy to test out the project template (the default code loads a list). The LoadListInfo method that loads the SharePoint list information is included below:

private void LoadListInfo()
 \{
 TextBlock textBlock = new TextBlock();
 foreach (List list in this._web.Lists)
 textBlock.Text += list.Title + " => " + list.Item
  Count + Environment.NewLine;
 ScrollViewer scrollViewer = new ScrollViewer
 \{
 HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
 VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
 Content = textBlock
 \};
 this.LayoutRoot.Children.Add(scrollViewer);
 \}

The result of the default code when you deploy and run the project is shown in Figure 2. You can see here all of the lists from a SharePoint site loaded along with the count of items within each list.

This is just a sample of the creativity and dedication of the SharePoint developer community, and many more extensibility projects will surely follow. You can find other examples of VS 2010 extensibility for SharePoint 2010 at Waldek Mastykarz's blog and cksdev.codeplex.com.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like