/// <summary> /// Creates a ReactiveCommand which will, when invoked, navigate to the /// type specified by the type parameter via looking it up in the /// Dependency Resolver. /// </summary> public static IReactiveCommand NavigateCommandFor <T>(this IRoutingState This) where T : IRoutableViewModel { var ret = new ReactiveCommand(This.Navigate.CanExecuteObservable); ret.Select(_ => (IRoutableViewModel)RxApp.DependencyResolver.GetService <T>()).InvokeCommand(This.Navigate); return(ret); }
/// <summary> /// Creates a ReactiveCommand which will, when invoked, navigate to the /// type specified by the type parameter via looking it up in the /// Dependency Resolver. /// </summary> public static IReactiveCommand NavigateCommandFor <T>(this RoutingState This) where T : IRoutableViewModel, new() { var ret = new ReactiveCommand <object>(This.Navigate.CanExecuteObservable, x => Observable.Return(x)); ret.Select(_ => (IRoutableViewModel)Locator.Current.GetService <T>() ?? new T()).InvokeCommand(This.Navigate); return(ret); }