When showing my main window, I create a list of objects from linq-to-sql:
using (var context = new Data.TVShowDataContext())
{
Shows = new ObservableCollection<Data.Show>(context.Shows);
listShows.ItemsSource = Shows;
}
Now that I double-clicked an item in my list, I want to use the selected object in the new usercontrol:
ShowEpList epList = new ShowEpList();
epList.DataContext = (Data.Show)listShows.SelectedItem;
This now throws an exception:
The System.ObjectDisposedException fix was an unhandled
Message = "Unable to access the remote object. \ R \ nObject: DataContext accessed after Dispose.".
Source = "System.Data.Linq"
ObjectName = "DataContext access after Dispose."
I suppose this happens as a result of linking the list to the list of seasons of the show, and the list of seasons should be populated or something else:
<ListBox Name="listSeasons" ItemsSource="{Binding Seasons}"/>
, , ?
DataContext , datacontext, ?
, ....