WPF-带有图像的列表框 [英] WPF -List Box with Images

查看:85
本文介绍了WPF-带有图像的列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

how to add any number of album art into listbox?.this is my code
<pre lang="c#"> 
        BitmapFrame bmp = null;
        public int Getpic(string s)
        {
           
            img.Source = null;
           string a = s;
            MemoryStream stream = null;
            TagLib.File file = TagLib.File.Create(a); //FilePath is the audio file location
            
            if (file.Tag.Pictures.Length >= 1)
            {
                TagLib.IPicture pic = file.Tag.Pictures[0];  //pic contains data for image.
                stream = new MemoryStream(pic.Data.Data);//create an in memory stream
                
                bmp = BitmapFrame.Create(stream);
                img.Source = bmp;
              
               
            }

推荐答案

您几乎可以将任何内容用于任何System.Windows.Controls.ItemControl的项目,包括具有属性ItemsSystem.Windows.Controls.ListBox.

请参阅:
http://msdn.microsoft.com/en-us/library/system. windows.controls.listbox.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.items.aspx [ ^ ].

—SA
You can use nearly any content to the items of any System.Windows.Controls.ItemControl, including System.Windows.Controls.ListBox, which has the property Items.

Please see:
http://msdn.microsoft.com/en-us/library/system.windows.controls.listbox.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.items.aspx[^].

—SA


这篇关于WPF-带有图像的列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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