I want to add declarations for a Object with type of ObservableCollection in Silverlight Xaml. This is what I have done.
1.Add the xmlns declaration like this:
xmlns:col="clr-namespace:System.Collections.ObjectModel;assembly=System.Windows"
2.Add the ObservableCollection declaration like this:
<col开发者_运维百科:ObservableCollection x:TypeArguments="sys:String" x:Key="AnaBase">
<sys:String>string1</sys:String>
<sys:String>string2</sys:String>
<sys:String>string3</sys:String>
</col:ObservableCollection>
3.The above code works fine in Vs2010 editor because it doesn't report any errors.
The problem is, when I try to build such xaml it always outputs error such as "The tag 'ObservableCollection' does not exist in XML namespace 'clr-namespace:System.Collections.ObjectModel;assembly=System.Windows'." It seems to me that the namespace resolvers in editing and building of VS work in different ways. Could anyone please to explain this phenomenon to me? Thanks a lot.
Finally I found out the answer. The generics is not supported in Silverlight 4. That's why ObservableCollection can't be seen in Intellisense of XAML.
Answer: WPF: Xaml, create an observable collection<object> in xaml in .NET 4.0
精彩评论