我有一个列表框,它绑定到从隔离存储中获取的图像,这是我获取这些图像的方式...
foreach (string fileName in fileStorage.GetFileNames("images//*.*"))
{
if (fileName == null)
break;
string filepath = System.IO.Path.Combine("images", fileName);
using (IsolatedStorageFileStream imageStream = fileStorage.OpenFile(filepath, FileMode.Open, FileAccess.Read))
{
var imageSource = PictureDecoder.DecodeJpeg(imageStream);
BitmapImage bitmapImage = new BitmapImage();
bitmapImage.SetSource(imageStream);
vltBitmapImage.Add(bitmapImage);
}
}
this.vaultbox.ItemsSource = vltBitmapImage;
现在我想删除选定的图像(可以选择多个)
if (vaultbox.SelectedItems.Count != 0)
{
MessageBoxResult m = MessageBox.Show("Files will be deleted forever", "Are you sure?", MessageBoxButton.OKCancel);
if (m == MessageBoxResult.Cancel)
vaultbox.SelectedIndex = -1;
else if(m==MessageBoxResult.OK)
{
foreach (BitmapImage item in vaultbox.SelectedItems)
{
//what should i do here?
}
}
}
else
MessageBox.Show("No file selected");