-
StackOverflow 文档
-
uwp 教程
-
图片
-
将 BitmapImage 与 Image 控件一起使用
<Image x:Name="MyImage" />
// Show image from web
MyImage.Source = new BitmapImage(new Uri("http://your-image-url.com"))
// Show image from solution
MyImage.Source = new Uri("ms-appx:///your-image-in-solution", UriKind.Absolute)
// Show image from file
IRandomAccessStreamReference file = GetFile();
IRandomAccessStream fileStream = await file.OpenAsync();
var image = new BitmapImage();
await image.SetSourceAsync(fileStream);
MyImage.Source = image;
fileStream.Dispose(); // Don't forget to close the stream