不能逻辑删除ListBox的ItemsSource

时间:2011-11-29 19:23:38

标签: windows-phone-7 listbox tombstoning

我有一个ListBox填充了来自XML的数据。 到目前为止,问题是我在尝试墓碑时遇到了一些错误。

protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
    {
        State["listbox1"] = listBox1.ItemsSource;
    }

然后:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        if (State.ContainsKey("listbox1"))
        {
            listBox1.ItemsSource = (IEnumerable)State["listbox1"];
        }
    }

当我点击开始按钮时,我已经收到错误消息。 App.xaml.cs打开,下面的行变为黄色

System.Diagnostics.Debugger.Break();

我也使用了墓碑帮助器,但它没有返回列表框中的项目。

1 个答案:

答案 0 :(得分:0)

列出的列表框是什么?你看到了什么错误?

如果是DataServiceCollection,您可能已启用跟踪&你不能把它断然地放在隔离存储或状态词典中。如果使用ObservableCollection,应该没问题。

谢谢!