Example #1
0
        public ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

            var nav = new PageNavigationService();

            // nav.Configure(MainPageKey, typeof(ApplicationViewModel));
            nav.Configure(MainPageKey, typeof(MainPage));
            nav.Configure(OtherPageKey, typeof(OtherPage));

            SimpleIoc.Default.Register <ApplicationViewModel>();
            SimpleIoc.Default.Register <MainPageViewModel>();
            SimpleIoc.Default.Register <OtherPageViewModel>();
            SimpleIoc.Default.Register <INavigationService>(() => nav);
        }
        static ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
            SimpleIoc.Default.Register <IDataService, ExpenseDataService>();
            SimpleIoc.Default.Register <AddExpenseViewModel>();
            SimpleIoc.Default.Register <SummaryViewModel>();

            var navigationService = new PageNavigationService();

            navigationService.Configure("Summary", new Uri("View/SummaryView.xaml", UriKind.Relative));
            SimpleIoc.Default.Register <IPageNavigationService>(() => navigationService);
        }