当绑定数据排序时,如何对 Silverlight 4 ListBox 项目进行动画处理?
我试图找出当与 ItemsSource 绑定的数据发生变化时到底会发生什么。那么我应该重写哪个方法才能使项目动画到排序列表中的新位置?
从到目前为止我发现的情况来看,我可能必须劫持 ListBox 内 ScrollViewer 的 LayoutUpdated ?我如何找出那里发生了什么以便能够将动画附加到 ListBoxItems 的位置分配?
实际上,使用一些附加的触发器和行为来做到这一点会更好,而不必扩展 ListBox 类。
编辑:事实证明 PagedCollectionView 和 CollectionViewSource 在排序时都会销毁并重新创建项目列表,因此如果不通过移动列表中的现有项目来手动实现排序或创建一些项目,则用动画重新排列列表似乎是不可能的某种项目缓冲区,这两者听起来都像是奇怪的错误和性能瓶颈的可能来源。如果有人对这些问题有可行的解决方案,我很乐意得到任何指示!
I'm trying to find out exactly what happens when the data bound with ItemsSource changes. So which method should I override to be able to make the items animate to their new positions in the sorted list?
From what I found out so far I might have to hijack the LayoutUpdated of the ScrollViewer inside the ListBox? How do I find out what happens there in order to be able to attach an animation to the ListBoxItems' position assignments?
Actually it would be even nicer to do this with some attached triggers and behaviors and not having to extend the ListBox class.
Edit: as it turned out both PagedCollectionView and CollectionViewSource destroys and recreates the item list on sorting, so rearranging the list with an animation doesn't seem to be possible without either implementing sorting manually by moving existing items around in the list or to create some sort of item buffer, both of which sounding like a possible source of weird bugs and performance bottleneck. If anyone has a working solution to these though I'd be glad to get any pointers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论