windows-phone-7 – 如何从Windows 7手机上的列表框中删除项目?

我使用ItemsSource,当我想从列表中删除一个项目时,我收到一个错误.
错误
只读集合不支持操作.
MenuItem menuItem = (MenuItem) sender;
        MessageBox.Show(menuItem.Header.ToString(),"Result",MessageBoxButton.OK);

        ListBoxItem lb (ListBoxItem)listBoxJournal.ItemContainerGenerator.ContainerFromItem(((MenuItem)sender).DataContext);

        liste.Remove((Note)lb.Content);
        listBoxJournal.UpdateLayout();
        listBoxJournal.Items.Clear();
        listBoxJournal.ItemsSource = liste;

我在行items.clear上得到了错误.
谢谢

如果在ListBox上设置ItemsSource,则Items在内部生成并且是只读的.
因此,在这种情况下,您需要从supoplied项集合中删除该项.
如果集合实现了INotifyCollectionChanged,则集合更改将反映在列表框中.

ObservableCollection是一个实现INotifyCollectionChanged的列表

相关文章

Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...
Windows文件操作基础代码 Windows下对文件进行操作使用的一段...
Winpcap基础代码 使用Winpcap进行网络数据的截获和发送都需要...
使用vbs脚本进行批量编码转换 最近需要使用SourceInsight查看...