public MainWindowViewModel(IViewModelFactory viewModelFactory) { BackCommand = new RelayCommand(() => GoBackOneViewModel(new GoToPreviousViewModel()), CanGoBackOneViewModel); viewModelFactory.CreateChildWindowViewModel(viewModelFactory); var allListsVm = viewModelFactory.CreateAllListsViewModel(); var goToAllListsVm = new GoToViewModel(allListsVm); ChangeCurrentViewModel(goToAllListsVm); Messenger.Default.Register<GoToViewModel>(this, ChangeCurrentViewModel); Messenger.Default.Register<GoToPreviousViewModel>(this, GoBackOneViewModel); }
private void ChangeCurrentViewModel(GoToViewModel goToViewModel) { var viewModel = goToViewModel.ViewModel; CurrentViewModel = viewModel; _previousViewModels.Add(viewModel); }