Last active
August 29, 2015 14:12
-
-
Save detroitpro/8bb2b02e597ab985e711 to your computer and use it in GitHub Desktop.
Xamarin Forms 1.3.1 Navigation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Mumsee.Mobile.Core.ViewModels | |
| { | |
| public class AppBootstrapper : ReactiveObject //, IScreen | |
| { | |
| // The Router holds the ViewModels for the back stack. Because it's | |
| // in this object, it will be serialized automatically. | |
| //public RoutingState Router { get; protected set; } | |
| public AppBootstrapper () | |
| { | |
| //Router = Router ?? new RoutingState (); | |
| Locator.CurrentMutable.RegisterConstant (this, typeof(IScreen)); | |
| // Set up Akavache | |
| // | |
| // Akavache is a portable data serialization library that we'll use to | |
| // cache data that we've downloaded | |
| BlobCache.ApplicationName = "Mumsee.Mobile"; | |
| // Set up Fusillade | |
| // | |
| // Fusillade is a super cool library that will make it so that whenever | |
| // we issue web requests, we'll only issue 4 concurrently, and if we | |
| // end up issuing multiple requests to the same resource, it will | |
| // de-dupe them. We're saying here, that we want our *backing* | |
| // HttpMessageHandler to be ModernHttpClient. | |
| Locator.CurrentMutable.RegisterConstant (new NativeMessageHandler (), typeof(HttpMessageHandler)); | |
| // CoolStuff: For routing to work, we need to tell ReactiveUI how to | |
| // create the Views associated with our ViewModels | |
| //Locator.CurrentMutable.Register (() => new LoadingView (), typeof(IViewFor<LoadingViewModel>)); | |
| // Kick off to the first page of our app. If we don't navigate to a | |
| // page on startup, Xamarin Forms will get real mad (and even if it | |
| // didn't, our users would!) | |
| //Router.Navigate.Execute (new LoadingViewModel (this)); | |
| } | |
| public Application CreateMainPage () | |
| { | |
| return new MainApp (); | |
| } | |
| } | |
| public class MainApp : Application | |
| { | |
| public MainApp () | |
| { | |
| MainPage = new NavigationPage (new LoadingView ()); | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The incompatibly is that in 1.3 all Xamarin forms app derive from Application, ReactiveUI can't just return a navigation page. The RoutedViewHost that is normally returned is a NavigationPage