如何在控件渲染时显示一些动画?
我有 WPF ListBox
显示大量数据。我需要平滑滚动,因此我将 ListBox.ScrollViewer.CanContentScroll 设置为 False 以禁用虚拟化。现在,当我打开放置此 ListBox
的选项卡时,我在几秒钟内看不到任何内容,因为 ListBox
正在加载/创建项目/渲染。我还有一个控件,显示一些动画,表明应用程序正在运行,用户应该稍等一下。
当 ListBox
不可用时如何显示此控件?
I have WPF ListBox
that shows a lot of data. I need smooth scrolling, so I've set ListBox.ScrollViewer.CanContentScroll
to False that disables virtualization. Now when I open the tab where this ListBox
is placed, I see nothing for few seconds because ListBox
is loading/creating items/rendering. I also have a control that shows some animation that indicates that application is running and user should wait a bit.
How can I show this control while ListBox
is not available?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在列表框的位置添加一个网格,并将列表框和动画控件放置在其中。这样它们就被放置在同一位置。动画控件应位于 z 顺序的顶部并如此显示。一旦列表框完成加载,您将隐藏动画控件,因此列表框将显示。每当您需要执行另一个长时间操作时,您都可以将动画控件再次设置为可见。
Add a Grid in the location of your list box and place inside it your ListBox and your animation control. This way they are placed in the same location. The animation control should be on the top of the z-order and so displayed. Once the ListBox has finished loading you would then hide the animation control and so the ListBox would show instead. Any time you need to perform another long operation you set the animation control to visible again.
在 Silverlight 和 WPF 应用程序中干净关闭
检查此应用程序的作者如何通过代码做到这一点,也许它可以帮助您,尽管这是不同的情况。
Clean shutdown in Silverlight and WPF applications
Check how the author of this application did it via code maybe it can help you though it is different scenario.