在WPF中,当用户滚动列表框并显示时,如何将图像加载到列表框中. [英] In WPF How can we load images in to listbox as user scrolls the listbox and display.

查看:86
本文介绍了在WPF中,当用户滚动列表框并显示时,如何将图像加载到列表框中.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我的文件夹中有约1000张.jpg图像,现在我想在列表框中显示这些图像的图像编号.
为此,我拍摄了一组图像并将其设置为列表框项源.但是该应用程序非常慢,因为它一次将所有图像都加载到列表框中.

所以我不想一次加载所有图像.我想每次加载10张图像并在列表框中显示,因为用户将滚动条导航到末尾,我想加载下一张图像并显示.

任何人都可以帮助我,如何在用户滚动列表框并显示时如何将图像加载到列表框中.


谢谢,

Hello,

I have some 1000 .jpg images in a folder, Now i want to display these images with image number in a listbox.
For this i have taken a collection of images and set as listbox item source. but the application is very slow as it is loading all the images at a time in to listbox.

so i dont want to load all the images at a time. i want to load 10 images each time and display in the listbox as the user navigates the scroll bar to the end i want to load next images and display.

any one help me How can we load images in to listbox as user scrolls the listbox and display.


Thanks,

推荐答案

一次显示一个图像通常足够快,如果该图像的大小等于或大于屏幕大小,但为1000左右,也就不足为奇了.太慢了.

您可以尝试几种不同的方法.首先,您只能在列表框中放入小缩略图图像.我希望您能理解:不是UI中按比例缩小的图像,而是不同的图像,较大的图像的副本以较小的尺寸预先渲染.现在,一次只显示一个大图像.处理列表框中项目的选择事件,并在侧面显示一个大图像.请了解:用户不需要查看更多内容.

现在,即使使用缩略图大小,一次显示所有图像仍可能会很多.您可以尝试通过数据绑定虚拟化"列表框.这样,它将只保留不超过同时显示在屏幕上的图像数量的图像.它需要一些思考,但确实可行.请参阅以下讨论: http://social.msdn .microsoft.com/forums/zh-CN/wpf/thread/cd08eb55-650e-4f2e-83dc-b58672c467a4 [
Showing one image at a time is usually fast enough, if the image is of the screen size or even more, but 1000 or so… no wonder it''s too slow.

You can try few different things. First, you can put only small thumbnail-size images in your list box. I hope you understand: not the images scaled down in the UI, but different images, the copies of bigger images pre-rendered with some small size. Now, show just one big image at a time. Handle the event of selection of an item in the list box and show a big image on the side. Please understand: the users don''t need to see more.

Now, even with the thumbnail size, showing all images at a time could be still to much. You can try to "virtualize" the list box through data binding. In this way, it will keep only the number of images not much more than the number visible on a screen at the same time. It needs some thinking, but quite doable. Please see this discussion: http://social.msdn.microsoft.com/forums/en-US/wpf/thread/cd08eb55-650e-4f2e-83dc-b58672c467a4[^].

—SA


似乎您需要在wpf中进行虚拟化,因此请查看以下页面:

WPF:数据虚拟化 [ http://social.msdn.microsoft.com/论坛/en-US/wpf/thread/98090161-0abf-4799-bbcb-852dcc0f0608 [ http://stackoverflow.com/questions/5599552/lazy-loading-of-non-可见元素 [ ^ ]

希望对您有所帮助.
It seems that you need virtualization in wpf , so have look at these pages :

WPF: Data Virtualization[^]

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/98090161-0abf-4799-bbcb-852dcc0f0608[^]

http://stackoverflow.com/questions/5599552/lazy-loading-of-non-visible-elements[^]

Hope it helps.


这篇关于在WPF中,当用户滚动列表框并显示时,如何将图像加载到列表框中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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