在 silverlight 应用程序中,我将 BitmapImage 定义为System.Windows.Media.Imaging.BitmapImage
,并将其定义为一个名为 " SetSource
" 的方法,在其中我可以像这样设置源:
BitmapImage bitmap = new BitmapImage();
System.IO.Stream stream = _scene.GetStream();
if (stream == null) return;
bitmap.SetSource(stream);
在 WPF 应用程序中,我还定义了一个位图图像,System.Windows.Media.Imaging.BitmapImage
但没有 SetSource 方法。如何像在 Silverlight 应用程序中一样在 WPF 应用程序中设置源?
此外,它是一个流,而不是一个字符串。它不是 URI。所以“UriSource”方法不起作用。我试过这个:
System.IO.Stream stream = _scene.GetStream();
if (stream == null) return;
BitmapImage bitmap = new BitmapImage();
bitmap.UriSource = new Uri(stream.ToString());
并且在运行时,它抛出了一个无法确定 URI 的错误。URI 是 Intranet 的标识符吗?你确定这不是银光吗?我正在做一个 WPF 应用程序