-
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