Example #1
0
        public void PresentAsNavigatableMainPage(BaseViewModel viewModel)
        {
            Page page = viewLocator.CreateAndBindPageFor(viewModel);

            NavigationPage newNavigationPage = new NavigationPage(page);

            IEnumerable <BaseViewModel> viewModelsToDismiss = FindViewModelsToDismiss(App.Current.MainPage);

            if (App.Current.MainPage is NavigationPage navPage)
            {
                navPage.PopRequested -= NavPagePopRequested;
            }

            viewModel.BeforeFirstShown();

            // Listen for back button presses on the new navigation bar
            newNavigationPage.PopRequested += NavPagePopRequested;
            App.Current.MainPage            = newNavigationPage;
            viewModel.OnAppearing();

            foreach (BaseViewModel toDismiss in viewModelsToDismiss)
            {
                toDismiss.AfterDismissed();
            }
        }
        public async Task NavigateTo(BaseViewModel viewModel)
        {
            var page = _viewLocator.CreateAndBindPageFor(viewModel);

            await viewModel.BeforeFirstShown();

            await Navigator.PushAsync(page);
        }
Example #3
0
        public async Task NavigateToModal(BaseViewModel viewModel)
        {
            Page page = viewLocator.CreateAndBindPageFor(viewModel);

            await viewModel.BeforeFirstShown();

            await Navigator.PushModalAsync(page);

            await viewModel.OnAppearing();
        }
Example #4
0
        public async Task NavigateTo(BaseViewModel viewModel)
        {
            var page = _viewLocator.CreateAndBindPageFor(viewModel);

            await viewModel.BeforeFirstShown();

            if (Xamarin.Forms.Application.Current.MainPage is MasterDetailPage masterDetailPage)
            {
                masterDetailPage.IsPresented = false;
            }
            else if (Xamarin.Forms.Application.Current.MainPage is NavigationPage navigationPage && navigationPage.CurrentPage is MasterDetailPage nestedMasterDetail)
            {
                nestedMasterDetail.IsPresented = false;
            }

            await Navigator.PushAsync(page);
        }
        public void PresentAsMainPage(BaseViewModel viewModel)
        {
            var page = _viewLocator.CreateAndBindPageFor(viewModel);

            IEnumerable <BaseViewModel> viewModelsToDismiss = FindViewModelsToDismiss(_presentationRoot.MainPage);

            if (_presentationRoot.MainPage is NavigationPage navPage)
            {
                // If we're replacing a navigation page, unsub from events
                navPage.PopRequested -= NavPagePopRequested;
            }

            viewModel.BeforeFirstShown();

            _presentationRoot.MainPage = page;

            foreach (BaseViewModel toDismiss in viewModelsToDismiss)
            {
                toDismiss.AfterDismissed();
            }
        }
Example #6
0
        public void PresentAsMainPage(BaseViewModel viewModel)
        {
            Page currentPage         = viewLocator.CreateAndBindPageFor(viewModel);
            var  viewModelsToDismiss = FindViewModelsToDismiss(App.Current.MainPage);

            if (App.Current.MainPage is NavigationPage navPage)
            {
                // If we're replacing a navigation page, unsub from events
                navPage.PopRequested -= NavPagePopRequested;
            }

            viewModel.BeforeFirstShown();

            App.Current.MainPage = currentPage;
            viewModel.OnAppearing();


            foreach (BaseViewModel toDismiss in viewModelsToDismiss)
            {
                toDismiss.AfterDismissed();
            }
        }