2

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.

ohmantics
  • 1,799
  • 14
  • 16
hunter.wang
  • 123
  • 1
  • 6

2 Answers2

2

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.

hunter.wang
  • 123
  • 1
  • 6
0

Answer: WPF: Xaml, create an observable collection<object> in xaml in .NET 4.0

Community
  • 1
  • 1
Priyank
  • 10,503
  • 2
  • 27
  • 25
  • Priyank, thank you very much for your reply. But unfortunately that answer doesn't work in my case. Because in Silverlight the class ObservableCollection is defined in System.Windows.dll, not in System.dll. – hunter.wang Apr 13 '11 at 03:50