I have bound a ListBox to a SQL CE database with this code:
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:DatabaseWindow}}, Path=Database.Photos1}"
This ListBox is populated properly. But when I try to insert a row into the database (InsertOnSubmit + SubmitChagnes), the ListBox is not updated!
I have tried:
ListBox.Items.Refresh();
ListBox.GetBindingExpression(ListBox.ItemsSourceProperty).UpdateTarget();
ListBox.ItemsSource = null;
ListBox.ItemsSource = this.Database.Table;
None of these helped. How can I update a ListBox?!
PS: After reloading the database, the row appears in the ListBox. PPS: If anyone knows a tutorial for SQL CE with WPF where the insertion into a ListBox is shown - that would be great, too!