Edit Custom Webpart-Properties with Silverlight & COM

Jun 16, 2010 at 1:25 PM
Edited Jun 16, 2010 at 1:31 PM

Hi,

I'm using the client object model in a silverlight-application to interact with Sharepoint.

What I want to do is:

- Changing the value of a custom webpart-property

All I can do is changing the title of a webpart but nothing else.

I've had also found no examples how to do it.

Heres my code

 

public MainPage()
{
clientCxt = new ClientContext("http://localhost");      
home = clientCxt.Web.GetFileByServerRelativeUrl("/Pages/default.aspx");
            //get the web part manager
            LimitedWebPartManager wpm =
                  home.GetLimitedWebPartManager(PersonalizationScope.Shared);

            //create the LINQ query to get the web parts from 
            //the web part definition collection
            wpds = clientCxt.LoadQuery(
                        wpm.WebParts.Include(
                              wp => wp.Id,
                              wp => wp.WebPart)
                   );
          
            clientCxt.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnSuccess), new ClientRequestFailedEventHandler(OnFailed)); 
}
private void OnSuccess(Object sender, ClientRequestSucceededEventArgs args)
        {             
            home.CheckOut();
                        
            if (wpds.Count() == 0)              //no web parts found on this page

            { 
            }
            else
            {
                foreach (WebPartDefinition wpd in wpds)
                {
                    if (wpd.WebPart.Title == "Sandbox_Webpart")
                    {
                        wpd.WebPart.Title = "Changed Title";
                        
                        wpd.SaveWebPartChanges();
                    }

                    home.CheckIn("", CheckinType.MajorCheckIn);
                    clientCxt.ExecuteQuery();
                    
                                        
                }
            }

        }
Thanks!
With best regards
Chris