6

The class allows the propagations of data context from the collection to its members. But it is only for SilverLight.

More info for DepedencyObjectCollection can be found from this post.

If the equivalent doesn't exist, what's the necessary steps required to create one?

I observe the desire behavior from the RowDefinitionCollection class. But I couldn't figure out its implementation.

thanks

Community
  • 1
  • 1
Rushui Guan
  • 3,023
  • 1
  • 24
  • 26
  • 4
    Man, I can't wait for .Net 40! – RichardTowers Jan 08 '13 at 22:54
  • Are you perhaps looking for `System.Collections.ObjectModel.ObservableCollection`? – newb Jan 08 '13 at 23:37
  • 1
    No. ObservableCollection doesn't pass the data context to its elements. In order for data binding to work, T has to inherit from DependencyObject. There is no contraint on the T for ObservableCollection, so it wouldn't work out of the box. – Rushui Guan Jan 08 '13 at 23:58

1 Answers1

2

The short answer is NO.

But I no longer think it is the correct implementation anyway. I end up using a collection of FrameworkElement and add them into the LogicalChildren of the custom control. By doing so, DataContext are passed on to the FrameworkElement naturally and everything works as expected.

It seems that that's how RowDefinition class is implemented in .NET 4.0. However, Silverlight version of RowDefinition is derived from DependencyObject directly. The MSDN document shows Silverlight documentation by default and misdirected me to the older and incorrect approach.

Rushui Guan
  • 3,023
  • 1
  • 24
  • 26