I am attempting to write a simple Silverlight webpart that reads information from a list and then outputs it to a data grid. I can get all of the lists, their titles and their field titles fine but when I try to get a specific list's title and field titles I get nothing except an error.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

namespace SP2010
public partial class MainPage : UserControl

    ClientContext context;
    Web spWeb;
    List customerList;
    ListItemCollection allCustomers;
    public MainPage()
        this.Loaded += new RoutedEventHandler(MainPage_Loaded);

    void MainPage_Loaded(object sender, RoutedEventArgs e)
        context = new ClientContext(ApplicationContext.Current.Url);
        spWeb = context.Web;
        customerList = spWeb.Lists.GetByTitle("testlist");
        CamlQuery camlQuery = new CamlQuery();
        camlQuery.ViewXml =
        allCustomers = customerList.GetItems(camlQuery);
        context.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), new ClientRequestFailedEventHandler(OnRequestFailed));

    private void OnRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args)
    private void OnRequestFailed(Object sender, ClientRequestFailedEventArgs args)
        MessageBox.Show(args.ErrorDetails + "   " + args.Message);
    private void DisplayListData()
        List<SPCustomers> spCustomers = new List<SPCustomers>();
        foreach (ListItem item in allCustomers)
            spCustomers.Add(new SPCustomers
                IPAddress = customerList.Fields.GetByTitle("IP").ToString(),
                Make = item["make"].ToString(),
                Model = item["model"].ToString(),
                xCord = item["x"].ToString(),
                yCord = item["y"].ToString()

        MyOutput.ItemsSource = spCustomers;

This is the response I get from SharePoint

<?xml version="1.0" encoding="utf-8"?><soap:Envelope 
Uncaught Error:Unhandled Error in Silverlight Application The property or field has not
been initialized.It has not been requested or the request has not been executed. It may
need to be explicitly requested.
  at Microsoft.SharePoint.Client.ListItem.GetFieldValue(String fieldName)
  at Microsoft.SharePoint.Client.ListItem.get_Item(String fieldName)
  at SP2010.MainPage.DisplayListData()</message><file></file><line>1</line><stack>&lt;stack&gt;
&lt;browser name=&quot;Netscape&quot; version=&quot;5&quot; /&gt;
&lt;useragent&gt;Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.803.0 Safari/535.1&lt;/useragent&gt;

I'm sure there is something I missed, any help would be appreciated.

2 Answers 2


The Exception is complaining about one of Fields you are attempting to query in your list item:

Make = item["make"].ToString(),
Model = item["model"].ToString(),
xCord = item["x"].ToString(),
yCord = item["y"].ToString()

Make 100% sure that the field names are what you think they are. (Open the List Settings and click on the field and check what it's name is in the URL. Use that Name)

Also, do a test by just attempting to get item["Title"]

  • make, model, x, and y were all correct but the IP field while named IP was actually Title but it still does not display the values
    – BeardFist
    Jul 7, 2011 at 15:54
  • That was indeed the problem because I am getting the data correctly just the data grid isn't showing it as expected
    – BeardFist
    Jul 7, 2011 at 21:36
  • Hi, I suggest you start a new question so we can help you with the silverlight now working :-)
    – Fox
    Jul 8, 2011 at 13:26

You could try using jQuery with Silverlight for simplified access to the Client OM created through sharepoint's listdata.svc. Here's some info for that.

You could also try using Silverlight's WebClient class for making HTTP GETs and POSTs to the /_vti_bin/listdata.svc. More info on that here:

  • Inaccuracy in this answer - The Client OM runs within the Silverlight application and doesn't require jQuery to access ListData.svc.
    – James Love
    Jul 8, 2011 at 17:59
  • I never said that. What I was saying is that jQuery has much more simplified access to lists through listdata.svc than does Silverlight. I was merely suggesting that rather than using the Client OM through silverlight he use listdata.svc, which implements the Client OM.
    – Vap0r
    Jul 8, 2011 at 19:08
  • Ah, understood - using the REST APIs (which are a darn sight faster than using the managed OM).
    – James Love
    Jul 8, 2011 at 19:56
  • Fully agree with James. Using Jquery with Silverlight was the way to go for Sharepoint 2007. Whereas this was a suitable solution, it requires the developer to build his/her own object model. Sharepoint 2010 has a built in Client Object model which is safer and faster.
    – Fox
    Jul 11, 2011 at 11:55
  • Note Vap0r.. Not trying to disprove your answer as it's also very valid. Just pointing to the fact that the recommended way of Client side dev in 2010 is using the Client OM. MS realised that there was a big need for Ajax loading and thus they built the Client OM.
    – Fox
    Jul 11, 2011 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.