WPF ListView动画按项目重新排序? [英] WPF ListView animation by reorder of items?

查看:235
本文介绍了WPF ListView动画按项目重新排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做几年前在WPF演示中看到的事情。我不知道它是如何完成的,但我知道可以做到这一点,这就是我的问题。

I want to do something I saw during a WPF demo some years ago. I don't know how it was done but I know it can be done so that is my problem.

在演示中,有一个带有ListView或ListBox的WPF应用程序有很多物品每个ListView被重新排序,项目在列表中的更改位置。但是ListView并不仅刷新了,实际上还有一些动画将它们移动到新位置。

In the demo there was an WPF application with a ListView or ListBox with a lot of items. Every the ListView was reordered the items changed places in the list. But the ListView was not just refreshed in fact there was an animation of the items moving to their new positions.

此应用程序非常酷,现在这正是我所要的需要。我们计划制作一个实时数据排名应用,这种动画将是完美的。

This application was very cool and right now this is exactly what I need. We plan to do a live-data-ranking-apps and this kind of animation would be perfect.

但是我们团队中没有人知道如何做到这一点。 。我在考虑ObservableCollection和Databinding,但其余的对我来说完全是个谜。

But no one in my team has an idea how this can be done. I am thinking of an ObservableCollection and Databinding but the rest is a total mystery to me.

任何提示或想法都会有很大帮助。我相信有人已经做到了。当WPF刚开始时,我用自己的眼睛看到了它,但我不知道从哪里开始寻找。

Any hint or idea would be a great help. I am sure someone has done that already. I saw it with my own eyes when WPF was new but I have no idea where to start looking.

推荐答案

进行自定义面板的可能性。查理(Charlie)关于覆盖布局非常正确。要创建自定义面板,您首先必须重写从继承的 MeasureOverride ArrangeOverride 方法System.Windows.Controls.Panel

There is also the possibility of doing a custom Panel. Charlie is pretty much right about overriding layout. To create a custom Panel, you primarily have to override the MeasureOverride and ArrangeOverride methods inherited from System.Windows.Controls.Panel.

此项目在CodeProject上演示了几个自定义面板,您可以在其中研究它们的动画效果。 FanPanel 动画使一项从一行的结尾移到另一行的开头或反之亦然。

This project on CodeProject demonstrates a couple custom panels in which you could study how they animated. The FanPanel animates the repositioning of items when one moves from the end of one row to the beginning of another or vice-versa.

本教程还演示了 ArrangeOverride 中的开始动画。

This tutorial also demonstrates beginning animations in ArrangeOverride.

我还没有'尝试过,但是您也可以将等级值与自定义的 ValueConverter 一起使用,以将等级转换为位置,从而在画布。不过,自定义面板最好是独立的,它允许您更改已排序数据上使用的 DataTemplate ,并让每个参数告诉 Panel 他们想要多高(假设它们垂直排列)。

I haven't tried it, but you may also be able to use the rank value along with a custom ValueConverter to convert the rank to a position in order to drive such an animation within a Canvas. A custom panel would be better self-contained, though, allowing you to change the DataTemplate used on your ranked data and let each of those tell the Panel how tall they want to be (assuming they're arranged vertically).

这篇关于WPF ListView动画按项目重新排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆