第二次绑定到 PointCollection 未呈现
我有一个 ItemsControl,我为其 ItemsSource 分配(通过代码)INotifyPropertyChanged 对象(数据模型)的 ObservableCollection(我们称之为 Items)。该数据模型具有 PointCollection 属性。
视图 (XAML) 绑定到 PolyLine 上的此 PointCollection(在 Points 属性上)。 最初,当我将此 Items 集合设置为 ItemsControl.ItemsSource 时,我可以看到线条确实已渲染。
问题: 当我将 ItemsControl.ItemsSource 设置为其他内容(例如另一个没有任何行的 ObservableCollection)然后将其设置回原始集合时,我无法看到这些行,即使该集合应该呈现它们,因为集合数据模型包含 PointCollection。
根据我的研究,绑定到 PointCollection 有一些特别棘手的地方。我想知道是否有人之前解决过这个问题和/或知道如何让它渲染(即使控件无效以某种方式强制重绘)???
谢谢。
I have an ItemsControl whose ItemsSource I assign (via code) an ObservableCollection (lets call it Items) of INotifyPropertyChanged objects (data model). This data model has a PointCollection property.
The view (XAML) binds to this PointCollection on a PolyLine (on the Points attribute).
Initially when i set this Items collection to the ItemsControl.ItemsSource, i can see that the lines are indeed rendered.
Issue:
When I set the ItemsControl.ItemsSource to something else (like another ObservableCollection which doesn't have any lines) THEN set it back to the original collection, I am unable to see the lines, even though the collection SHOULD render them because the collection data model's contain the PointCollection.
From what I was able to research, there is something particularly tricky about binding to a PointCollection. I was wondering if anybody has tackled this before and/or know of a way to get this to render (i.e. invalidate the control to somehow force a redraw)???
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Alvin,
我不知道这是否可行,但是,您是否尝试过创建一个新的 PointCollection?:
如果这不起作用,也许可能需要使用更基于 WPF 的语法:
我自己正在努力解决一些 PointCollection 问题,所以如果这些选项中的任何一个都有帮助,请告诉我。
Alvin,
I have no idea if this will work but, have you tried creating a new PointCollection?:
If that doesn't work, maybe it may be necessary use a more WPF based syntax:
I am struggling with some PointCollection issues myself so if either of these options help, let me know.