Binding to a collection of DependencyObjects in Silverlight 4

橙三吉。 提交于 2019-12-07 17:14:05

问题


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:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!