private void SetupWizard(WizardControllerViewModel viewModel) { if (viewModel == null) { throw new ArgumentNullException(nameof(viewModel)); } if (_currentViewModel != null) { DisconnectCurrentModel(); } ConnectViewModel(viewModel); }
void ConnectViewModel(WizardControllerViewModel viewModel) { if (viewModel == null) { throw new ArgumentNullException(nameof(viewModel)); } _currentViewModel = viewModel; _currentViewModel.StartWizard(); foreach (var pageViewModel in viewModel.PageModels) { var pageView = _viewFactory.CreatePage(pageViewModel); Children.Add(pageView); } _currentViewModel.Current.ObserveOn(Scheduler.UiScheduler).Subscribe((vm) => { var viewIndex = _currentViewModel.GetPageIndex(vm); var view = Children[viewIndex]; CurrentPage = view; }); }