1
votes

I need to show a silverlight webpart in sharepoint 2010.

This is my code, to show silverlight control

protected override void CreateChildControls()
{
    Silverlight sl = new Silverlight();
    sl.ID = "CustomWebPart1SL";
    sl.Source = "/Silverlight/CustomWebPart.xap";
    this.Controls.Add(sl);
}

In Silverlight I just hotcoded the data so the chart is rendering correctly in Sharepoint page.

The problem is I couldn't access Sharepoint list from silverlight application.

How to access the list and property-bag from silverlight application. Or how can I pass those datas as DataTable to silverlight from WebPart code.

And silverlight not supporting DataTable object. What is the reason.

2

2 Answers

2
votes

For SilverLight I should suggest using of Client Object Model for SharePoint. For good starting point you should visit: this

0
votes

Silverlight applicatons run on the client machine, Sharepoint on the a server. The only way a Silverlight application can access Sharepoint lists is by Client Object Model (if you are running on Sharepoint 2010) or consuming Sharepoint web services (on Sharepoint 2007 or previous).

There are many out-of-the-box services in the /_vti_bin/ folder useful for reading and writing anything.

Alternatively you can save an xml file containing your data in a document library and read it from the Silverlight application. But this means that you have to update the xml content everytime the source list is updated (with event receivers or using a scheduled job).