需要在ListBox中绑定ISO Stores文件

时间:2012-03-29 14:56:59

标签: windows-phone-7 listbox

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

public ImageSource Image
    {

        get {
            try
            {

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

                return image;
            }
            catch (Exception)
            {

                return null;
            }

        }

我不明白缺少什么

1 个答案:

答案 0 :(得分:0)

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