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?
我正在从webservice中检索一个类,并且在这个类中有一个泛型列表,但不知何故它被转换为ObservableCollection。我将webservice集合类型配置为通用列表但无济于事。有没有理由说明为什么会这样?
2 个解决方案
#1
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
这是服务引用的配置。在visual studio中,只需右键单击服务引用并编辑属性即可。应该有一个集合类型的设置。默认情况下,它设置为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.
编辑:只看我的解决方案,上下文菜单选项是“配置服务引用”,要设置的属性是“集合类型”。您还可以设置要使用的字典类型。
#2
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.
Silverlight需要使用可观察集合才能正确绑定到集合(实现INotifyCollectionChanged的集合)。如果您使用Visual Studio中的所有Web服务,如果这种情况自动发生,我不会感到惊讶。
#1
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
这是服务引用的配置。在visual studio中,只需右键单击服务引用并编辑属性即可。应该有一个集合类型的设置。默认情况下,它设置为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.
编辑:只看我的解决方案,上下文菜单选项是“配置服务引用”,要设置的属性是“集合类型”。您还可以设置要使用的字典类型。
#2
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.
Silverlight需要使用可观察集合才能正确绑定到集合(实现INotifyCollectionChanged的集合)。如果您使用Visual Studio中的所有Web服务,如果这种情况自动发生,我不会感到惊讶。