public MainViewModel(ReadingEntity readingModel) { // Publish an event with eventName = PubSubTest. Others can subscribe to said eventName, in order to catch when it is raised PubSub <object> .PublishEvent("PubSubTest", PubSubCheckedHandler); // ReadingModel contains a list of movie objects data fetched from the database this.readingModel = readingModel; // Initialize other viewmodels WatchedMoviesViewModel = new WatchedMoviesViewModel(readingModel.WatchedMovies); // Pass list of movie objects to the WatchedMovies NonWatchedMoviesViewModel = new NonWatchedMoviesViewModel(readingModel.NonWatchedMovies); // Pass list of movie objects to the NonWatchedMovies AddMovieViewModel = new AddMovieViewModel(this, WatchedMoviesViewModel, NonWatchedMoviesViewModel); // Pass reference for mainviewmodel and both datagrids, so when we add a new movie we know where to put it // Subscribe to the ViewModels' OnpropertyChanged event WatchedMoviesViewModel.PropertyChanged += MoviesViewModel_PropertyChanged; NonWatchedMoviesViewModel.PropertyChanged += MoviesViewModel_PropertyChanged; this.PropertyChanged += MainWindowViewModel_PropertyChanged; // Subscribe to MainViewModels OnPropertyChanged event to check for changes in MainViewModel // Register commands so we are able to execute specific buttons RegisterCommand(SaveCommand = new ActionCommand(Save, CanSave)); RegisterCommand(LoadCommand = new ActionCommand(Load, CanLoad)); RegisterCommand(TestCommand = new ActionCommand(Test, CanTest)); }