(WPF)动画ListView项举措 [英] (WPF) Animate ListView item move

查看:225
本文介绍了(WPF)动画ListView项举措的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想当ListView的项目改变位置有一个动画,所以它会慢慢地移动到新位置。无论是在模板或code。
我试图从(虚拟化)的StackPanel下降并重写ArrangeOverride重新定位和动画项目。问题是,我不知道在什么位置的项目是之前更新,所以我可以很好地过渡到新的位置。我试图检查项目的TranslateTransform,在字典中存储,覆盖OnItemChanged和存储OldPosition /位置..但有没有工作,因为它似乎在项目总是(从模板)创建。

I would like to have an animation when an item in ListView changes position, so it would slowly move to the new position. Either in a template or in code. I've tried descending from a (Virtualizing)StackPanel and overriding ArrangeOverride to reposition and animate the items. the problem is that I don't know at what position the item was 'before' the update so I could transition to the new position nicely. I tried checking the TranslateTransform of the item, storing in a dictionary, overriding OnItemChanged and storing OldPosition/Position .. but none of there work because it seems the items are always recreated (from template).

任何其他建议?

推荐答案

使用FluidMoveBehavior行为,它会使你的生活轻松了许多。

Use FluidMoveBehavior behaviour , it will make you life lot easier.

您可以通过以下方式将此任何的ItemsControl

you can apply this to any itemscontrol in the following manner

<ItemsPanelTemplate x:Key="ItemsPanelTemplate">
            <WrapPanel>
                <i:Interaction.Behaviors>
                    <il:FluidMoveBehavior AppliesTo="Children" Duration="00:00:00.75"/>
                </i:Interaction.Behaviors>
            </WrapPanel>
</ItemsPanelTemplate>

你可以找到在与混合3一起安装的Microsoft.Ex pression.Interactions.dll这种行为

you can find this behaviour in the Microsoft.Expression.Interactions.dll that is installed along with Blend 3

这篇关于(WPF)动画ListView项举措的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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