简体   繁体   中英

How to show a WCFinformation in Silverlight?

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?

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM