为什么删除列表框中的项目后数据库没有加载?
if (result == MessageBoxResult.OK)
{
int _id = int.Parse(((System.Windows.FrameworkElement)(e.OriginalSource)).Tag.ToString());
string strDel = "Delete from category where id=" + _id;
(Application.Current as App).db.Delete<Category>(strDel);
LoadData();
}
在LoadData中我绑定了items.But它在刷新后没有显示项目。
private void loaddata()
{
string strSelect = "SELECT id,categoryid,subcategname FROM category";
_categoryEntries = (Application.Current as App).db.SelectObservableCollection<Category>(strSelect);
if (_categoryEntries != null)
{
foreach (Category data in _categoryEntries)
{
switch (data.categoryid)
{
case 0:
app.Add(data);
ApplicationsListBox.ItemsSource = app;
break;
}
}
}
}