Binding to a collection of DependencyObjects in Silverlight 4
Asked Answered
R

1

3

As of Silverlight 4 it is possible to data bind against a DependencyObject (instead of a Framework element in previous versions). So far so good, but how do I bind agains a collection of DependencyObjects.

The DataContext is not passed from the ObservableCollection to the collection elements, so that the DependencyProperties of the DependencyObjects are never called (neither the changed events). Neither the DependencyObject offers SetBinding or DataContext to initialize the binding manually.

Thanks for any advice here.

Ravine answered 9/5, 2010 at 13:16 Comment(0)
U
3

To get the DataContext to propagate in this case, the DependencyProperty that holds the collection must be of type DependencyObjectCollection<T>. DataContext propagates through DependencyProperties and DependencyObjectCollections.

Urmia answered 10/5, 2010 at 22:54 Comment(1)
Any ideal how to replicate this for .NET 4.0?Scanner

© 2022 - 2024 — McMap. All rights reserved.