Wednesday, February 10, 2010

Adding Silverlight application(.xap file) in sharepoint web part.

Import the System.Web.UI.SilverlightControls to use the silverlight control.

Create the object of Silverlight control and specify the path of .xap file. Add this control in web part.

Silverlight silverlightControl = new Silverlight();
silverlightControl.ID = "DemoId";
silverlightControl.Source = "~/_layouts/1033/Demo.xap";
silverlightControl.Width = Unit.Percentage(100);
silverlightControl.Height = new Unit(400);
silverlightControl.AutoUpgrade = true;

this.Controls.Add(silverlightControl);

No comments: