Ok this is derived from the sample Listviews with Multiple Views. I added a button which chooses a file in a directory and then gets all the files from the directory and adds them to the list view. I generically set every item to the cat image.
using Microsoft.Win32;
using System.Collections.Generic;
lv.ItemsSource = null;
List<XmlElement> elements = new List<XmlElement>();
Microsoft.Win32.FileDialog fd = new Microsoft.Win32.OpenFileDialog();
bool ?a = fd.ShowDialog();
if (a == true)
{
XmlDocument doc = new XmlDocument();
string dir = fd.FileName.Remove(fd.FileName.Length - fd.SafeFileName.Length, fd.SafeFileName.Length);
string[] files = Directory.GetFiles(dir);
foreach (string file in files)
{
XmlElement item = doc.CreateElement(file.Remove(0,dir.Length));
item.SetAttribute("Name", file.Remove(0, dir.Length));
item.SetAttribute("Type", Path.GetExtension(file));
item.SetAttribute("Image", "images\\cat.png");
elements.Add(item);
}
}
lv.ItemsSource = elements;