绑定到 Silverlight 4 中的 DependencyObject 集合

发布于 2024-08-31 11:27:40 字数 314 浏览 0 评论 0原文

从 Silverlight 4 开始,可以针对 DependencyObject(而不是以前版本中的 Framework 元素)进行数据绑定。到目前为止一切顺利,但如何再次绑定 DependencyObjects 集合。

DataContext 不会从 ObservableCollection 传递到集合元素,因此 DependencyObject 的 DependencyProperties 永远不会被调用(也不会调用更改的事件)。 DependencyObject 都不提供 SetBinding 或 DataContext 来手动初始化绑定。

感谢您在这里提供任何建议。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北音执念 2024-09-07 11:27:40

要在这种情况下传播 DataContext,保存该集合的 DependencyProperty 类型必须为 DependencyObjectCollection 类型。 DataContext 通过 DependencyProperties 和 DependencyObjectCollections 进行传播。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文