Ejemplo n.º 1
0
        void setupRx()
        {
            if (rxObjectsSetup)
            {
                return;
            }

            NavigateBack = new ReactiveCommand(
                NavigationStack.CollectionCountChanged.StartWith(_NavigationStack.Count).Select(x => x > 0));
            NavigateBack.Subscribe(_ =>
                                   NavigationStack.RemoveAt(NavigationStack.Count - 1));

            Navigate = new NavigationReactiveCommand();
            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 NavigationReactiveCommand();
            NavigateAndReset.Subscribe(x => {
                NavigationStack.Clear();
                Navigate.Execute(x);
            });

            rxObjectsSetup = true;
        }
Ejemplo n.º 2
0
        void setupRx()
        {
            NavigateBack = new ReactiveCommand(
                NavigationStack.CountChanged.StartWith(_NavigationStack.Count).Select(x => x > 1));
            NavigateBack.Subscribe(_ =>
                                   NavigationStack.RemoveAt(NavigationStack.Count - 1));

            Navigate = new NavigationReactiveCommand();
            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 NavigationReactiveCommand();
            NavigateAndReset.Subscribe(x => {
                NavigationStack.Clear();
                Navigate.Execute(x);
            });

            CurrentViewModel = Observable.Concat(
                Observable.Defer(() => Observable.Return(NavigationStack.LastOrDefault())),
                NavigationStack.Changed.Select(_ => NavigationStack.LastOrDefault()));
        }
Ejemplo n.º 3
0
 public FakeRoutingState()
 {
     NavigateBack = new ReactiveCommand();
     Navigate     = new NavigationReactiveCommand();
 }