Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(WPF) Animate ListView item move

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).

Any other suggestions?

like image 313
Lee_Nover Avatar asked Aug 22 '09 23:08

Lee_Nover


Video Answer


1 Answers

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

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>

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

like image 53
rravuri Avatar answered Oct 12 '22 11:10

rravuri