views:

37

answers:

1

Hi everyone. I have a Silverlight application that displays a map, and my intention is, when I mouse over a specific location in the map, the information about this location gets displayed somehow in the app. What I've done so far is to link the silverlight app to a webservice that retrieves this information for me, but now I'm stuck, and don't know how to proceed. I was following this tutorial., but when the tutorial wants to retrieve a list, I want to retrieve a single object. I was trying to use the datagrid, but I think it was not designed to perform what I want. I need some enlightment to tell me how to proceed.

Well ... I'll edit the code to show what problem I'm having. My code behind have this two methods:

private void MouseOverHarbor(object sender, RoutedEventArgs e)
        {
            Ellipse thisPath = (Ellipse)sender;

            thisPath.Stroke = mySolidColorBrush;
            DataRetrieverReference.Service1Client webService = new DataRetrieverReference.Service1Client();
            webService.GetDataCompleted += new EventHandler<DataRetrieverReference.GetDataCompletedEventArgs>(webService_GetDataCompleted);

            webService.GetDataAsync((int)thisPath.DataContext);      

        }

        void webService_GetDataCompleted(object sender, DataRetrieverReference.GetDataCompletedEventArgs e)
        {
            NameField.Text = "Works";//No, it doesnt!            
        }

What I can see is that the event handler is never reached, but I don't know why. I just used the same code the tutorials taught, but I didn't achieve my goal yet. Am I missing something?

A: 

Remove the List< > part from List<Customer> in your calls and keep only the Customer part.

Change your queries from

var matchingCustomers = from cust in db.Customers
                        where cust.LastName.StartsWith(lastName)
                        select cust;
return matchingCustomers.ToList();

to

var matchingCustomers = from cust in db.Customers
                        where cust.LastName.StartsWith(lastName)
                        select cust;
return matchingCustomers.FirstOrDefault();
Albin Sunnanbo
The problem is that the Silverlight data grid wont allow me to use a non-enumerable value in the ItemsSource field.
Bruno
@Bruno: Why would you use a grid to display a single value? Another control might be more suitable. If you want to convert a single value to a List you can do: List<Customer> customerList = new List<Customer>{singleCustomer};
Albin Sunnanbo