WPF Image显示图片,文件被占用异常
imageControl.Source = this.GetBitmapImage(imagePath);//imageControl为WPF Image控件
public BitmapImage GetBitmapImage(string imagePath)
{
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.UriSource = new Uri(imagePath);
bitmap.EndInit();
return bitmap.Clone();
}
版权声明:本文为博主原创文章,未经博主允许不得转载。

浙公网安备 33010602011771号