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.
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.
来源:https://stackoverflow.com/questions/2797717/binding-to-a-collection-of-dependencyobjects-in-silverlight-4