Ejemplo n.º 1
0
        public RoutedViewHost()
        {
            HorizontalContentAlignment = HorizontalAlignment.Stretch;
            VerticalContentAlignment   = VerticalAlignment.Stretch;
            routerChange = new Subject <IRoutingState>();

            routerChange.Subscribe(x => {
                if (_inner != null)
                {
                    _inner.Dispose();
                    _inner = null;
                }

                _inner = x.ViewModelObservable().Subscribe(vm => {
                    if (vm == null)
                    {
                        Content = DefaultContent;
                        return;
                    }

                    var view       = RxRouting.ResolveView(vm);
                    view.ViewModel = vm;
                    Content        = view;
                });
            });
        }
Ejemplo n.º 2
0
        public ViewModelViewHost()
        {
            this.ObservableFromDP(x => x.ViewModel)
            .Subscribe(vm => {
                if (vm.Value == null)
                {
                    Content = DefaultContent;
                    return;
                }

                var view       = RxRouting.ResolveView(vm.Value);
                view.ViewModel = vm.Value;
                Content        = view;
            });
        }
Ejemplo n.º 3
0
        public ViewModelViewHost()
        {
            var latestViewModel = updateViewModel
                                  .Select(_ => (ViewModel ?? DataContext))
                                  .StartWith((object)null);

            latestViewModel.Subscribe(vm => {
                if (vm == null)
                {
                    Content = DefaultContent;
                    return;
                }

                var view       = RxRouting.ResolveView(vm);
                view.ViewModel = vm;
                Content        = view;
            });
        }
Ejemplo n.º 4
0
        public ViewModelViewHost()
        {
            var latestViewModel = Observable.CombineLatest(
                this.ObservableFromDP(x => x.ViewModel).Select(x => x.Value).StartWith((IReactiveNotifyPropertyChanged)null),
                this.ObservableFromDP(x => x.DataContext).Select(x => x.Value).OfType <IReactiveNotifyPropertyChanged>().StartWith((IReactiveNotifyPropertyChanged)null),
                (vm, dc) => vm ?? dc);

            latestViewModel.Subscribe(vm => {
                if (vm == null)
                {
                    Content = DefaultContent;
                    return;
                }

                var view       = RxRouting.ResolveView(vm);
                view.ViewModel = vm;
                Content        = view;
            });
        }
Ejemplo n.º 5
0
        public RouterUINavigationController(IRoutingState router)
        {
            this.router = router;

            router.Navigate.Subscribe(x => {
                var view       = RxRouting.ResolveView(x);
                view.ViewModel = x;

                this.PushViewController((UIViewController)view, true);
            });

            router.NavigateBack.Subscribe(_ => this.PopViewControllerAnimated(true));
            router.NavigateAndReset.Subscribe(x => {
                this.PopToRootViewController(false);
                router.Navigate.Execute(x);
            });

            this.Delegate = new RouterUINavigationControllerDelegate(this, router);
        }
Ejemplo n.º 6
0
        public RoutedViewHost()
        {
            this.ObservableFromDP(x => x.Router)
            .Subscribe(x => {
                if (_inner != null)
                {
                    _inner.Dispose();
                    _inner = null;
                }

                _inner = x.Value.CurrentViewModel.Subscribe(vm => {
                    if (vm == null)
                    {
                        Content = DefaultContent;
                        return;
                    }

                    var view       = RxRouting.ResolveView(vm);
                    view.ViewModel = vm;
                    Content        = view;
                });
            });
        }
Ejemplo n.º 7
0
        public RoutedViewHost()
        {
            HorizontalContentAlignment = HorizontalAlignment.Stretch;
            VerticalContentAlignment   = VerticalAlignment.Stretch;

            if (RxApp.InUnitTestRunner())
            {
                return;
            }

            this.WhenAny(x => x.Router.NavigationStack, x => x.Value)
            .SelectMany(x => x.CollectionCountChanged.StartWith(x.Count).Select(_ => x.LastOrDefault()))
            .Subscribe(vm => {
                if (vm == null)
                {
                    Content = DefaultContent;
                    return;
                }

                var view       = RxRouting.ResolveView(vm);
                view.ViewModel = vm;
                Content        = view;
            }, ex => RxApp.DefaultExceptionHandler.OnNext(ex));
        }