UWP 显示图片到Image控件
生活随笔
收集整理的這篇文章主要介紹了
UWP 显示图片到Image控件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
要想顯示圖片,前提是要有一個空間的啦
<Image x:Name="imageHidden"/>?
然后一個響應選擇圖片得事件,注意使用asynchronous方法哦
?
FileOpenPicker picker = new FileOpenPicker();picker.FileTypeFilter.Add(".jpg");picker.FileTypeFilter.Add(".jpeg");picker.FileTypeFilter.Add(".png");picker.FileTypeFilter.Add(".bmp");picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;var file = await picker.PickSingleFileAsync();if (file != null){IRandomAccessStream ir = await file.OpenAsync(FileAccessMode.Read);BitmapImage bi = new BitmapImage();await bi.SetSourceAsync(ir);imageHidden.Source = bi;}?
注意,需要勾選“圖片庫”的權限哦。
?
轉載于:https://www.cnblogs.com/hupo376787/p/7624809.html
總結
以上是生活随笔為你收集整理的UWP 显示图片到Image控件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [NIO系列]NIO源码分析之Buffe
- 下一篇: Appium移动自动化配置-ios安卓