【发布时间】:2009-04-27 15:02:57
【问题描述】:
我已使用以下代码将 ListBox 绑定到 SQL CE 数据库:
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:DatabaseWindow}}, Path=Database.Photos1}"
此 ListBox 已正确填充。但是当我尝试向数据库中插入一行时(InsertOnSubmit + SubmitChagnes),ListBox 没有更新!
我试过了:
ListBox.Items.Refresh();
ListBox.GetBindingExpression(ListBox.ItemsSourceProperty).UpdateTarget();
ListBox.ItemsSource = null;
ListBox.ItemsSource = this.Database.Table;
这些都没有帮助。如何更新 ListBox?!
PS:重新加载数据库后,该行出现在列表框中。 PPS:如果有人知道带有 WPF 的 SQL CE 教程,其中显示了插入到 ListBox 中 - 那也很棒!
【问题讨论】:
标签: c# .net sql database sql-server-ce