How to refresh LongListSelector after delete an item

女生的网名这么多〃 提交于 2019-12-06 16:38:22

Without seeing more of the code, it's hard to be sure what's going wrong. But if you are setting

ListRecentFiles.DataContext = NoteItems;

that is incorrect. You want to set

ListRecentFiles.ItemsSource = NoteItems;

The XAML declaration:

ItemSource="{Binding}"

Could do that (depending on the rest of the code). Once .ItemsSource is set correctly, then the line:

NoteItems.Remove(selectedNote); 

Should succeed in removing the visual item from the LongListSelector. In any case, you should not do the line:

ListRecentFiles.ItemsSource.Remove(item);

That would do the wrong thing when the list gets so big that it doesn't all fit in memory at once.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!