// Extension Methods

        // *** Navigation ***

        #region public static void Navigate(this IRoutingState router, IRoutableViewModel viewModel, IRoutingParams routingParams)

        /// <summary>
        /// Navigates the specified router.
        /// </summary>
        /// <param name="router">The router.</param>
        /// <param name="viewModel">The view model.</param>
        /// <param name="routingParams">The routing parameters.</param>
        public static void Navigate(this IRoutingState router, IRoutableViewModel viewModel, IRoutingParams routingParams)
        {
            if (router != null)
            {
                router.Navigate.Execute(new RoutableViewModelWithParams(viewModel, routingParams));
            }
        } 
 /// <summary>
 /// Navigates the specified router.
 /// </summary>
 /// <param name="router">The router.</param>
 /// <param name="viewModel">The view model.</param>
 /// <param name="notInNavigationStack">if set to <c>true</c> [not in navigation stack].</param>
 public static void Navigate(this IRoutingState router, IRoutableViewModel viewModel, bool notInNavigationStack)
 {
     router.Navigate(viewModel,
         new RoutingParams
         {
             NotInNavigationStack = notInNavigationStack
         });
 } 
Example #3
0
        IObservable<Page> pageForViewModel(IRoutableViewModel vm) 
        {
            if (vm == null) return Observable.Empty<Page>();

            var ret = ViewLocator.Current.ResolveView(vm);
            if (ret == null) {
                var msg = String.Format(
                    "Couldn't find a View for ViewModel. You probably need to register an IViewFor<{0}>",
                    vm.GetType().Name);

                return Observable.Throw<Page>(new Exception(msg));
            }

            ret.ViewModel = vm;

            var pg = (Page)ret;
            pg.Title = vm.UrlPathSegment;
            return Observable.Return(pg);
        }
 /// <summary>
 /// Navigates the specified router.
 /// </summary>
 /// <param name="router">The router.</param>
 /// <param name="viewModel">The view model.</param>
 /// <param name="notInNavigationStack">if set to <c>true</c> [not in navigation stack].</param>
 /// <param name="reuseExistingView">if set to <c>true</c> [reuse existing view].</param>
 public static void Navigate(this IRoutingState router, IRoutableViewModel viewModel, bool notInNavigationStack, bool reuseExistingView)
 {
     router.Navigate(viewModel,
         new CustomRoutingParams
         {
             NotInNavigationStack = notInNavigationStack,
             ReuseExistingView = reuseExistingView
         });
 } 
 /// <summary>
 /// Navigates the specified view model.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 /// <param name="notInNavigationStack">if set to <c>true</c> [not in navigation stack].</param>
 /// <exception cref="System.NotImplementedException"></exception>
 public void Navigate(IRoutableViewModel viewModel, bool notInNavigationStack = false)
 {
     var viewModelWithParams = viewModel as IRoutableViewModelWithParams;
     if (viewModelWithParams != null)
     {
         if (viewModelWithParams.RoutingParams != null)
         {
             viewModelWithParams.RoutingParams.NotInNavigationStack = notInNavigationStack;
         }
         else
         {
             viewModelWithParams.RoutingParams = new RoutingParams { NotInNavigationStack = notInNavigationStack };
         }
         
         AppModel.Router.Navigate(viewModelWithParams.RoutableViewModel, viewModelWithParams.RoutingParams);
     }
     else
     {
         AppModel.Router.Navigate(viewModel, notInNavigationStack);
     }
     
 } 
 /// <summary>
 /// Navigates the specified view model.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 /// <param name="routingParams">The routing parameters.</param>
 /// <exception cref="System.NotImplementedException"></exception>
 public void Navigate(IRoutableViewModel viewModel, IRoutingParams routingParams)
 {
     AppModel.Router.Navigate(viewModel, routingParams);
 } 
Example #7
0
        private UIViewController ResolveView (IRoutableViewModel viewModel, string contract)
        {
            if (viewModel == null) {
                return null;
            }

            var viewLocator = this.ViewLocator ?? ReactiveUI.ViewLocator.Current;
            var view = viewLocator.ResolveView (viewModel, contract);

            if (view == null) {
                throw new Exception (
                    string.Format (
                        "Couldn't find a view for view model. You probably need to register an IViewFor<{0}>",
                        viewModel.GetType ().Name));
            }

            view.ViewModel = viewModel;
            var viewController = view as UIViewController;

            if (viewController == null) {
                throw new Exception (
                    string.Format (
                        "View type {0} for view model type {1} is not a UIViewController",
                        view.GetType ().Name,
                        viewModel.GetType ().Name));
            }

            return viewController;
        }