U2U Blog

for developers and other creative minds

The Silverlight BluePrint for SharePoint on Silverlight Beta 2 available now!

The Silverlight BluePrint for SharePoint on Silverlight Beta 2 is finally available for download here.

“The updated release of the Silverlight Blueprint for SharePoint is a little different from the original blueprints as with this release we've created a set of self-contained samples that using the blueprint methodology you can deploy to your SharePoint site to test out the Silverlight applications. The goal of the blueprints is to give you some guidance on how to integrate Silverlight applications with SharePoint. There are many possibilities here, and we've put together just a few to get you started.”

We have built in the latest new features of Silverlight, like Visual State Manager, HTTPWebRequest, data binding,

Hello World sample

This is a simple web part sample that shows how you can host a silverlight application from within a SharePoint web part.

In the Silverlight 2 beta 1 BluePrint for SharePoint we always deployed to a sub folder of the ClientBin that resides in the SharePoint web application but in this version of the Blueprint we also deployed to other locations. This sample contains a SharePoint web part that deploys to a document library and a web part that deploys to the LAYOUTS folder.

Slider custom field sample

This is a SharePoint custom field type containing a Silverlight slider. No major changes are made to this sample. As for the Silverlight 2 beta 1 BluePrint for SharePoint, the technique for using the InitParams property for the Silverlight control is explained here.

Media Viewer web part sample

This web part illustrates the use of a Picture Library containing pictures or movies. Information like the URL of the SharePoint site, the name of the Picture Library and the type of media is passed in the InitParams property of the Silverlight control. The data for the pictures is downloaded from within the Silverlight application using the HttpWebRequest object. This technique works completely asynchronous know. Changes to the Silverlight code itself include the use of the built-in ListBox control customized with styles and data binding.

The SharePoint web part is deployed to a document library.

Colleague Viewer web part sample

This sample illustrates the use of a WCF service for displaying colleague information out of the UserProfileManager. The WCF service runs in the SharePoint context. This WCF service is called from within the Silverlight application. Silverlight techniques used are styles and data binding.

The SharePoint web part is deployed to a SharePoint document library.

Navigation Control sample

This controls shows how you can develop a custom navigation control hosting a silverlight control. The data for the silverlight application is retrieved from within SharePoint and passed in an XML Data Island that can be accessed by the Silverlight application. Silverlight techniques used here are data binding and Visual State Manager to build the navigation scroll viewer. The silverlight application comes with a SharePoint master page feature.

Have fun with it! Hope you like it.

Deploying a Silverlight application as an Embedded Resource

While my world stopped turning 10 days ago, technology has not. The coming weeks I will post things I stopped working on because my work for Patrick took too much of my (free) time. By keeping up the work I hope to honor him. Thanks for the many words of support and the condolences.

When integrating Silverlight applications with SharePoint custom development, you have different possibilities where to deploy your silverlight application:

- To the ClientBin folder of your IIS web application: If you deploy in this location, it means that the Silverlight application can be picked up by any SharePoint code that runs in the site collections and sites hosted on the IIS Web Application.

- To the 12\Template\Layouts or in the 12\Template\ControlTemplates folder: deploying here means that you can include all of the deployment steps in your SharePoint Solution.

- To a document library: you can create one central document library within your site collection (or if you want a more narrow scope, for your site) where to drop the XAP files.

I refer to the post of Patrick Tisseghem for more details, advantages and disadvantages of each possibility.

In this post I will show you how you can deploy your Silverlight application as an embedded resource of your web part. In that case the Silverlight application will only be available to that web part.

The first step is to build your silverlight application. I used the Hello Silverlight 2.0 application from the Silverlight BluePrint for SharePoint.

Create your web part

Then create your web part. I used the SharePoint WebPart template for Visual Studio 2008.

Add a reference to the following DLLs:

- System.Web.Silverlight.dll (version 2.0.5.0)

- System.Web.Extensions.dll (version 3.5.0.0)

Add your silverlight application (.xap) to your Visual Studio project. I created a Resources directory for it. Set the properties of the xap to Embedded Resource. Don't forget this because otherwise the Silverlight application will not be compiled as embedded resource.

image 

Open the Web Part class. Before the namespace declaration add the metadata attribute that enables an embedded resource in an assembly:

[assembly: WebResource("EmbeddedSilverlightWebPart.Resources.SL.XAML.HelloSilverlight20.xap", "application/x-silverlight-app")]

Check the correct namespace with Reflector.

Add a class level variable for the Silverlight control. This control resides in the System.Web.Silverlight namespace.

Silverlight silverlightControl;

Override the OnLoad event to check whether a Script Manager already lives on the Web Part page.

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);

    // Script manager instance may appear only once on a page
    ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
    if (scriptManager == null)
    {
        scriptManager = new ScriptManager();
        this.Controls.AddAt(0, scriptManager);
    }
}

Instantiate the Silverlight control in the CreateChildControls method and add it to the Controls collection. The Source property of the silverlight control need to be set to the location of the embedded resource. This location can be detected by using the  this.Page.ClientScript.GetWebResourceUrl method:

protected override void CreateChildControls()
{
    base.CreateChildControls();

    this.Width = new Unit("400");
    this.Height = new Unit("200");

    string xapUrl = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "EmbeddedSilverlightWebPart.Resources.SL.XAML.HelloSilverlight20.xap");
    silverlightControl = new System.Web.UI.SilverlightControls.Silverlight()
    {
        ID = "EmbeddedSlCtl",
        MinimumVersion = "2.0.30523",
        Source = xapUrl,
        Width = new System.Web.UI.WebControls.Unit(400),
        Height = new System.Web.UI.WebControls.Unit(200)
    };
    this.Controls.Add(silverlightControl);
}

Override the RenderContents method:

protected override void RenderContents(HtmlTextWriter writer)
{
    EnsureChildControls();
    if (silverlightControl != null)
        silverlightControl.RenderControl(writer);
}

That's it. Build your code.

Deploy the web part

Make the necessary changes to the .webpart file and the .xml file if you want to. Patrick learned me to always add the web part to a significant group in the Web Part Gallery:

<Elements Id="1eba021c-8a0f-4bf2-8f2e-1c9d8f36bf7f" xmlns="http://schemas.microsoft.com/sharepoint/" >
  <Module Name="WebParts" List="113" Url="_catalogs/wp">
    <File Path="EmbeddedSilverlight.webpart" Url="EmbeddedSilverlight.webpart" Type="GhostableInLibrary">
      <Property Name="Group" Value="Silverlight" />
    </File>
  </Module>
</Elements>

Deploy the web part to your SharePoint site. If you use the Visual Studio 2008 extensions for SharePoint, you only have to enter the URL of your SharePoint site in the project properties and press F5.

Don't forget to configure your SharePoint sites for enabling Silverlight if not yet done.

Add the Web Part to a Web Part page

image

You can download the sample web part here.

Thanks to Stefaan Rillaert for pointing me in the right direction.

Profke

On Wednesday evening my best friend Patrick Tisseghem passed away, 1 year and one month after his friend David Boschmans. At this very moment I still cannot believe it. He still had so many plans.

Patrick, I’m so glad I had the chance to know you. Ten years ago you were only a hero speaking at small conferences but since the day we met in person, we became friends, good friends and it felt like we knew each other for ever. We could share everything: good feelings, bad feelings. Whenever I had a problem or a dip, I always turned to you and you were always there to help me out. I consider myself lucky that I was able to return you the favor on many occasions. Even when you were abroad we talked every single day. Thanks to you I achieved things that I never dared dream of.

Dearest friend, since the day we met I've always followed your trail. You were my guide I trusted unconditionally. But your trail doesn’t stop here. You will always be my guiding light. You will always be on my mind.

You will last forever.

U2U List Properties Feature: new version released...

This feature adds an hyperlink to the List Settings page of your list. When clicking it, a page with detailed information about the list properties is displayed.

U2U List Properties

You can read detailed information about this feature here.

This new version contains a bug fix for workflow properties.

You can download the feature here.

 Remark: The U2U List Properties feature previously was part of the U2U SharePoint Solution Package. If you installed this solution, you will have to retract and delete this solution before you can install the new solution. The other features like U2U CAML Query Builder and U2U Site Properties will be available soon in separate solutions.