void setupRx() { if (rxObjectsSetup) { return; } NavigateBack = new ReactiveCommand( NavigationStack.CollectionCountChanged.StartWith(_NavigationStack.Count).Select(x => x > 1)); NavigateBack.Subscribe(_ => NavigationStack.RemoveAt(NavigationStack.Count - 1)); Navigate = new NavigationCommand(); Navigate.Subscribe(x => { var vm = x as IRoutableViewModel; if (vm == null) { throw new Exception("Navigate must be called on an IRoutableViewModel"); } NavigationStack.Add(vm); }); NavigateAndReset = new NavigationCommand(); NavigateAndReset.Subscribe(x => { NavigationStack.Clear(); Navigate.Execute(x); }); rxObjectsSetup = true; }
public MainWindowViewModel(IRegionManager regionManager) { this.RegionManager = regionManager; NavigationCommand.Subscribe <string>(viewName => { this.RegionManager.RequestNavigate("ContentRegion", viewName); }); }