在WPF中将图像加载到ListBox中 [英] Loading Images into ListBox IN WPF

查看:72
本文介绍了在WPF中将图像加载到ListBox中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想将图像显示到WPF中的ListBox中.我要实现的是以下目标

1.从设备读取图像,并获取名称等信息.(完成)
2.在列表框中创建项目,并显示默认的拇指(一些默认图片)代替实际的拇指,因为稍后将为图像读取拇指. (完成)
3.现在获取其缩略图并将其存储在文件夹中(完成).正在完成任务.

4.现在显示图像的实际缩略图. ( 未完成).

第4步是我被困住的地方.基本上,我要执行的操作类似于窗口,该窗口将首先显示图像/视频图标,然后再用拇指按下.

请帮忙.我是WPF的新手,因此遇到了问题.

Hi,

I want to display images into a ListBox in WPF. What i want to achieve is following

1. Read from a device for images and get information like name etc. (DONE)
2. create items in listbox and display default thumb (some default pic) in place of actual thumb as thumb will be read later for the image. (DONE)
3. Now get their thumbnails and store them in a folder (DONE). Being done by a task.

4. NOW show the actual thumb of the image. ( NOT DONE).

STEP 4 is where i am stuck. Basically what i want to do is similar to windows which will first display images/videos icon then fill their thumbs.

Please help. I am new to WPF and hence facing problems.

推荐答案

在您的XAML中,找到ListBox.

将xaml修改为类似的代码("...."是您的代码,只需保持原样即可.).

In your XAML, locate the ListBox.

Modify the xaml, into something like this ("...." is your code, just leave it as it be).

<listbox x:name="...." xmlns:x="#unknown">
  <listbox.itemtemplate>
     <datatemplate>
        <grid>
          <image source="{Binding}" height="150" width="150" />
        </grid>
     </datatemplate>
  </listbox.itemtemplate>
  ....
</listbox>



如果需要更多信息,请查看一些讨论WPF数据绑定的文章.

希望这会有所帮助.



If you need more information, please look at some articles discussing WPF Data Binding.

Hope this helps.


这篇关于在WPF中将图像加载到ListBox中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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