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