在Windows 8 Metro C#中显示StorageFile
发布时间:2020-12-14 02:11:14 所属栏目:Windows 来源:网络整理
导读:我想在资产管理系统的UI上显示一个图像文件.我设法将项目存储为StorageFile.我该如何显示它?我试图在XAML Image中显示它.标签的来源.是否有可能将StorageFile转换为Image? string path = @"Assetsmypicture.png";StorageFile file = await InstallationFo
我想在资产管理系统的UI上显示一个图像文件.我设法将项目存储为StorageFile.我该如何显示它?我试图在XAML<
Image>中显示它.标签的来源.是否有可能将StorageFile转换为Image?
string path = @"Assetsmypicture.png"; StorageFile file = await InstallationFolder.GetFileAsync(path); 解决方法
试试这个功能
public async Task<Image> GetImageAsync(StorageFile storageFile) { BitmapImage bitmapImage = new BitmapImage(); FileRandomAccessStream stream = (FileRandomAccessStream)await storageFile.OpenAsync(FileAccessMode.Read); bitmapImage.SetSource(stream); Image image = new Image(); image.Source = bitmapImage; return image; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- 是否可以将变量传递到Windows FTP脚本文件?
- microsoft-graph – 包含Microsoft Graph查询过滤
- windows – 没有QApplication或QCoreApplication
- windows10 Ubuntu子系统下卸载Mysql重装
- windows – 捕获VBScript中的任何错误?
- 窗口 – 微小读取(重叠,缓冲)的表现超过大型连续
- 使用.NET 4.5编写的软件需要什么版本的.NET运行时
- windows-server-2008-r2 – 安装Server 2008 R2
- VS在调用dll时候出现Run-Time Check Failure #0,
- Windows Phone 8仿真器 – 部署通用应用程序导致
热点阅读