0
我已绑定列表框与此代码的SQL CE数据库:更新列表框
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:DatabaseWindow}}, Path=Database.Photos1}"
此列表框填充正确。但是,当我尝试向数据库插入一行(InsertOnSubmit + SubmitChagnes)时,ListBox不会更新!
我曾尝试:
ListBox.Items.Refresh();
ListBox.GetBindingExpression(ListBox.ItemsSourceProperty).UpdateTarget();
ListBox.ItemsSource = null;
ListBox.ItemsSource = this.Database.Table;
的这些帮助无。我如何更新ListBox?
PS:重新加载数据库后,该行出现在列表框中。PPS:如果有人知道使用WPF插入到ListBox的SQL CE的教程 - 那也太棒了!
是的,我知道这就是ListBox不会自动更新*的原因。但是如果我可以手动更新它就足够了。 – eWolf 2009-04-27 18:39:56