简体   繁体   中英

WPF animation on a ListBox

Do you know any example of how to animate the insertion of an item on a ListBox ? The effect I was thinking of is something like:

  • At first we have items A and B on the ListBox .

  • Than a C item is inserted between A and B .

  • In the effect I imagined, before C is inserted, A and B become gradually more distant until a C element fits in between. When we reach this point, C is finnally inserted.

My problem is that, even though I already did something about templates (that I could animate), I don't know how to slowly separate two items on the ListBox .

Any ideas?

Thanks in advance

Insert the C item first, but with height 0 and with its content hidden (or transparent). Then animate the height of the C item to its full height: this will push A and B apart. Finally, make the content of the C item visible (or animate its opacity into visbility).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM