C# 将图像从隔离存储加载到可观察的集合不工作

C# 将图像从隔离存储加载到可观察的集合不工作,c#,windows-phone-7,C#,Windows Phone 7,我正在从应用程序中的独立存储设置加载映像路径 [DataMember] public string entryImage = ""; [DataMember] public string EntryImage { get { return entryImage; } set { entryImage = value; } } 使用助手类将图像存储到独立的存储文件中 public static void S

我正在从应用程序中的独立存储设置加载映像路径

    [DataMember]
    public string entryImage = "";

    [DataMember]
    public string EntryImage
    {
        get { return entryImage; }
        set { entryImage = value; }
    }
使用助手类将图像存储到独立的存储文件中

    public static void SaveImage(Stream imageStream, string directory, string filename)
    {
        try
        {
            string path = System.IO.Path.Combine(directory, filename);

            using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!isoStore.DirectoryExists(directory)) isoStore.CreateDirectory(directory);

                using (var writeStream = isoStore.CreateFile(path))
                {
                    byte[] buffer = new byte[32768];
                    while (true)
                    {
                        int read = imageStream.Read(buffer, 0, buffer.Length);

                        if (read <= 0)
                            return;
                        writeStream.Write(buffer, 0, read);
                    }
                }
            }

        }
        // Catch exception if unable to save the image
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
其中MyDiaryItem是可观察的集合

        MyDiaryItem _saveItems = new MyDiaryItem();
        _saveItems.EntryNotes = InputText.Text;
        _saveItems.EntryDate = date.ToString();
        _saveItems.EntryImage = AppHelper.ImageDirectory + AppSettings.ImageFilename;
 public ObservableCollection<MyDiaryItem> diaryItems = null;
public-observeCollection-diaryItems=null;
隔离存储—保存和加载

         void LoadSettings()
    {
        if (settings.Contains("DiaryItems"))
        {
            diaryItems = new ObservableCollection<MyDiaryItem>((List<MyDiaryItem>)settings["DiaryItems"]);
        }
    }

    void SaveSettings()
    {
        //settings["DiaryItems"] = diaryItems.ToList();
        if (diaryItems.ToList() != null)
        {
            settings.Clear();
            settings.Add("DiaryItems", diaryItems.ToList());
            settings.Save();
        }
    }
void LoadSettings()
{
if(settings.Contains(“DiaryItems”))
{
diaryItems=新的ObservableCollection((列表)设置[“diaryItems”]);
}
}
void SaveSettings()
{
//设置[“日记项”]=DiaryItems.ToList();
if(diaryItems.ToList()!=null)
{
设置。清除();
Add(“DiaryItems”,DiaryItems.ToList());
设置。保存();
}
}
下面是图像源的xaml代码

            <ListBox toolkit:TiltEffect.IsTiltEnabled="true" Name="AllEntriesList"
                     Margin="0,0,-12,0"
                     SelectionChanged="AllEntriesList_SelectionChanged">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" Margin="0,0,0,17">
                            <Image Source="{Binding EntryImage}" Height="100" Width="100" Stretch="Fill" Margin="12,0,9,0" />
                            <StackPanel Margin="0,0,0,17" Width="350" Height="Auto">
                                <TextBlock Text="{Binding EntryLocation}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}" />
                                <TextBlock Text="{Binding EntryNotes}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" />
                                <TextBlock Text="{Binding EntryDate}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" />
                            </StackPanel>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

我想了解如何使用从独立存储中检索的imagepath在diaryitems列表中显示图像

我正在加载OnNavigated中的所有日记项,以实现如下功能

AllEntriesList.ItemsSource=app.diaryItems


我可以在日记项列表中看到正确填充的图像名称。我想在日记项列表中显示图像。怎么做

@MyKuLLSKI-请不要编辑问题,说它可能是重复的。这就是“关闭”或“注释”的目的。@Erno-请显示引用此规则的链接。ThanksModerator注意到,这个问题下的评论已被删除,因为它们恶化为比信号更大的噪音。如果您觉得某个问题重复,请将其标记或投票关闭,或者在不确定的情况下留下评论,指出可能重复的问题。请勿编辑原始帖子以建议重复。如果问题是重复的,请给我现有问题的链接,以便我可以找到答案。
 <Image Source="{Binding EntryImage}" Height="100" Width="100" Stretch="Fill" Margin="12,0,9,0" />
 BitmapSource CreateSource(Stream stream)
 { 
     return source = PictureDecoder.DecodeJpeg(stream);
 }