【问题标题】:Need to bind ISO Stores file in a ListBox需要在 ListBox 中绑定 ISO Stores 文件
【发布时间】:2019-06-13 00:53:14
【问题描述】:

我正在尝试存储一些带有通过 PhotoChooserTask 从 ISO 存储中选择的图像标记的声音剪辑。 我可以在独立的图像框中成功显示图像,但是当我在列表框中设置图像框源时,它不显示图像。 目前我正在做的是这样的:

public ImageSource Image
    {

        get {
            try
            {

                BitmapImage image;
                if(Category == 11)
                {
                 image = new BitmapImage(new Uri(this.ImageLocation));
                }

                return image;
            }
            catch (Exception)
            {

                return null;
            }

        }

我不明白缺少什么

【问题讨论】:

    标签: c# windows-phone-7 listbox


    【解决方案1】:

    BitmapImage 无法从Isolated Storage 加载图像。您需要手动读取文件图像

            BitmapImage bi = new BitmapImage();
    
            using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(this.ImageLocation, FileMode.Open, FileAccess.Read))
                {
                    bi.SetSource(fileStream);
                }
            }
            return bi;
    

    另外,如果这不起作用,请检查 CreateOptions 并将其设置为 None

    【讨论】:

    • 错误是什么?文件真的保存在这里吗?您可以使用Windows Phone Power Tools 来确保它在这里并且没有损坏
    • 我已经尝试过这种方式,但我遇到错误“IsolatedStorageFileStream 上不允许操作。”在执行isoStore.OpenFile(this.ImageLocation, FileMode.Open)时,文件位置的值为“\\Applications\\Data\\A7C5852D-9DD5-4B60-B2EA-8904E0F164FB\\Data\\PlatformData\\PhotoChooser- 9b8122a0-c3bb-4095-be4d-4f435dce6211.jpg"
    • 我正在使用 PhotoChooserTask,所以文件已经在存储中
    • PhotoChooserTask 不会自动将图像保存到Isolated Storage。要保存,请查看:stackoverflow.com/questions/7615095/…
    • 我必须将图像复制到应用程序存储文件夹吗?
    猜你喜欢
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-16
    相关资源
    最近更新 更多