示例#1
0
        public async Task NavigateToModal(ViewModelBase viewModel)
        {
            var page = _viewLocator.CreateAndBindPageFor(viewModel);

            await viewModel.BeforeFirstShown();

            await Navigator.PushModalAsync(page);
        }
        public async Task OpenModal(ViewModelBase viewModel, string viewName)
        {
            var page = _viewLocator.CreateAndBindPage(viewModel, viewName);

            await viewModel.BeforeFirstShown();

            await Navigator.PushModalAsync(page, true);
        }
示例#3
0
        public void PresentAsMainPage(ViewModelBase viewModel)
        {
            var page = _viewLocator.CreateAndBindPageFor(viewModel);

            IEnumerable <ViewModelBase> 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 (ViewModelBase toDismiss in viewModelsToDismiss)
            {
                toDismiss.AfterDismissed();
            }
        }
        public void PresentAsNavigatableMainPage(ViewModelBase viewModel)
        {
            var page = _viewLocator.CreateAndBindPage(viewModel);

            NavigationPage newNavigationPage = new NavigationPage(page);

            IEnumerable <ViewModelBase> viewModelsToDismiss = FindViewModelsToDismss(_presentationRoot.MainPage);

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

            viewModel.BeforeFirstShown();

            newNavigationPage.PopRequested += NavPagePopRequested;
            _presentationRoot.MainPage      = newNavigationPage;

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