Good afternoon,
I am trying to use as Linq to SQL datacontext for a ListBox in WPF.
Basically, I assign the Linq DataContext to the form's DataContext property. Then, I bind it to the list.ItemsSource.
Everything works fine, I can show the details of each of my elements in a textbox (master-details scheme).
The thing is, I would like to be able to add a new element to the list:
private void Button_Click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
var table = lst_markets.ItemsSource as System.Data.Linq.Table<Market>;
table.InsertOnSubmit(new Market() { IdMarket = Guid.NewGuid(), Name = txt_newmarket.Text });
table.Context.SubmitChanges();
}
The value is indeed added to the database, but the ListBox is not refreshed.
What should I do to refresh the list?
Thanks,
Jeremie