加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

在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;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读