将新项目添加到WPF ListBox时的滑动效果 [英] Sliding effect when adding new items to a WPF ListBox

查看:271
本文介绍了将新项目添加到WPF ListBox时的滑动效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF ListBox控件,用于显示RSS feed的项目.有时,我会在RSS feed的源中查找新项目.一旦检测到新项目,便将其添加到可观察的集合中,该集合立即将新项目添加到ListBox显示中.

I have a WPF ListBox control which displays items of an RSS feed. I occasionally check the source of the RSS feed for new items. Once I detect a new item I add it to the observable collection which immediately adds the new item to the ListBox display.

是否有办法从顶部推入"新项目,向下推现有项目?我将如何达到这样的效果?可以使用ListBox完成此操作,还是需要使用自己的容器,例如StackPanel并以编程方式设置动画(例如,新添加的控件的高度)?

Is there a way to 'slide in' the new item from the top, pushing down the existing items? How would I achieve such an effect? Can it be done with a ListBox, or do I need to resort to my own container, such as a StackPanel and animate for example the Height of newly added controls programmatically?

推荐答案

我刚刚发布了一个与您的问题非常相似的答案.

I just posted an answer to this question which is very similar to yours.

WPF如何为组件列表创建动画

这篇关于将新项目添加到WPF ListBox时的滑动效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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