tags:

views:

651

answers:

2

I am retreiving a class from a webservice and in this class there is a generic list, but somehow it is being turned into an ObservableCollection. I configured the webservice collection type to Generic Lists but to no avail. Is there a reason as to why this is happening?

A: 

Silverlight needs to use observable collections to be able to bind to collections properly (well collections that implement INotifyCollectionChanged). I wouldn't be surprised if this happens automatically if you're using all the webservice stuff inside Visual Studio.

mattmanser
+1  A: 

This is a configuration of the service reference. In visual studio, just right click on the service reference and edit the properties. There should be a setting for collection type. By default this is set to ObservableCollection

Edit: just looked at my solution, the context menu option is "Configure Service Reference" and the property to set is "Collection Type". You can also set the dictionary type to use.

Jacob Adams
I set it to generic list, works if I get the lists directly but if I get a class with a list inside it, it converts it into an observable collection
Drahcir
I just tried that out, and it didn't happen for me. It returned a list of items that each contained another list. I'm not sure if this helps, but do you have [DataContract] and [DataMember] attributes on your class/properties that you're returning?
Jacob Adams
Don't know how suddenly worked, maybe I missed something
Drahcir
You should note that Visual Studio sometimes doesnt obey the collection type you specify in the configuration window of the service reference. See here: http://forums.silverlight.net/forums/t/91817.aspx
Alex