I am trying to access a List on a view model from a background worker, but am getting errors because I am going cross thread...
This is the problem method on the viewmodel: (I am getting the exception the first line in the function (SMMainWindow window ...))
public static MainWindowViewModel GetMainWindowViewModel() {
SMMainWindow window = (SMMainWindow)System.Windows.Application.Current.MainWindow;
if (window != null) {
return (MainWindowViewModel)window.DataContext;
}
return null;
}
Any ideas? Sample code would be appreciated