原文:WPF中Image控件的Source属性 imgBook 是一个Image控件,在后台代码中我想给它指定Source的属性.我先如下方式进行: Uri uri = new Uri(strImagePath, UriKind.RelativeOrAbsolute); imgBook.Source = new BitmapImage(uri); strImagePath是图片的绝对路径. 在另一处代码中我想把strImagePath指定的图片删掉,操作如下: if (System.IO.Fil…
1.直接关联到文件,关联后不能删除此图片,因为图片正在使用. imageEditImage.Source = new BitmapImage(new Uri(strImagePath, UriKind.Absolute));//strImagePath 就绝对路径 2.转成二进制,与图片原文件脱离 var img = new BitmapImage(); img.BeginInit(); img.StreamSource = new MemoryStream(File.ReadAllBytes(…