我有一个文件列表,当我单击每个文件时,我希望它显示图像的预览。我想我有写代码,但我不确定 () 中的内容
this.listBox1.MouseUp += new System.Windows.Forms.MouseEventHandler();
我希望点击执行此操作
private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// get selected filename
string curItem = listBox1.SelectedItem.ToString();
// BitmapImage.UriSource must be in a BeginInit/EndInit block
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@curItem);
myBitmapImage.DecodePixelWidth = 200;
myBitmapImage.EndInit();
uploadImage.Source = myBitmapImage;
}