Binding to a collection of DependencyObjects in Si

2019-05-10 02:53发布

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.

1条回答
叼着烟拽天下
2楼-- · 2019-05-10 03:31

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.

查看更多
登录 后发表回答