views:

334

answers:

3

Here's my situation - I am starting my first SL application coming from a Windows background where I have the MVC pattern in place. I am thinking I can take advantage of tha pattern, so I jump right in to creating a SL application (solution) with 3 projects --> 1 holding my Model (business objects from before), SL app (automatically generated when I picked SL project), and 1 SL.Web project (automatically generated when I picked SL project).

Here are the steps I did: I dropped a blank grid onto my xaml file, created a service and it is being recognized w/o any problems. Added a "Silverlight-enabled WCF Service" to my Web project and w/in my project I referenced my "Model" project. Within [OperationContract], I created the following method (service):

[OperationContract]
public EmployeeCollection GetEmployees()
{
     EmployeeCollection employees = Model.EmployeeCollection.GetAllEmployees();
     return employees;
}

When I debug though this and put a breakpoint, I DO see data on return of employees, so I KNOW data is being returned.

Now, on my page.xaml.cs file, it seems that that my grid is not being populated somehow, but don't why.

I have the following snippet:

void MyWebService_GetEmploteesCompleted(object sender, EmployeeWebService.GetEmployeesCompletedEventArgs e)
{
     dataGrid.ItemsSource = e.Result;
}

Where else should I be looking? What can I be missing? Do I have to add other snippets of code to work w/ my BLL (Model)?

Thanks for any advice.

=============================

BTW, while debugging, in the "Autos" window, I notice the following values coming through on _GetEMployeesCompleted():

dataGrid.ItemSource ........... Count = 30 e.Result ......... Count = 30

Why aren't the values showing up on my DataGrid?

A: 

Did you set AutoGenerateColumns = true on the DataGrid? What interfaces does EmployeeCollection implement?

James Cadd
My grid is a plain grid w/ no properties set, so by default, AutoGenerateColumns should be true. Just to confirm, I went ahead and set the following:AutoGenerateColumns="True"/>As per the my _Collection, I have the following interfaces implemented: IDataErrorInfo, BindingList<T>, IBindingListView. Coming from Windows development, these objects/entities were not serialized, so I'm beginning to think that is the problem, but I've also read that with .NET 3.5 SP1, explicitly marking your custom classes with serialization and stuff like [DataMember] is no longer mandatory, correct?
A: 

Pardon the silly question, but since we don't see how the Employee class is implemented, does your Employee class expose public properties (not just public members)? You can only bind to properties, that might explain why DataGrid is not auto generating columns.

markti
Yes, like I noted above. This framework of my BLL and DAL works perfectly in my Windows forms. My question is, do I have to 'sprinkle' them with any extra to enable them for WCF or SL consumption?
DataContract and DataMember are of course required. I don't mean to be obvious but since we don't have enough info in the post.
Paully
Also instead of directly assigning to ItemSource are you making sure there are no exceptions in e.Errors
Paully
oh, nevermind on the e.Errors since you mentioned you are getting 30 objects in the e.Results
Paully
A: 

This question is a bit old, but I've ran into a similar problem...

Are you using the theme engine? I've noticed that using the grid inside of another control (ChildWindow, Tab, etc) with the Theme Engine causes the children to not render. I've raised a bug with the toolkit people, so we'll see if it gets fixed.

Travis