public INavigationOperation TryShowAsync(IViewModel viewModel, IDataContext context, IViewModelPresenter parentPresenter)
        {
            if (viewModel == this)
            {
                return(null);
            }

            var operation = new NavigationOperation();
            var callback  = operation.ToOperationCallback();

            //Saving callback to view model state that will allow us to execute it even after app save\restore cycle.
            _callbackManager.Register(NavigationType, viewModel, callback, context);
            OnShowViewModel(viewModel);
            return(operation);
        }
        public IAsyncOperation TryShowAsync(IDataContext context, IViewModelPresenter parentPresenter)
        {
            var viewModel = context.GetData(NavigationConstants.ViewModel);

            if (viewModel == null)
            {
                return(null);
            }

            var navigationOperation = new AsyncOperation <object>();

            _callbackManager.Register(SplitViewNavigationType.Operation, viewModel, navigationOperation.ToOperationCallback(), context);

            //waiting when all navigations will be completed (Page, Window) to be sure that the MainViewModel is the top view model.
            parentPresenter.WaitCurrentNavigationsAsync(context)
            .ContinueWith(task => OnCurrentNavigationsCompleted(viewModel), TaskScheduler.FromCurrentSynchronizationContext());
            return(navigationOperation);
        }
        public IAsyncOperation TryShowAsync(IDataContext context, IViewModelPresenter parentPresenter)
        {
            var viewModel = context.GetData(NavigationConstants.ViewModel);

            if (viewModel == null || !CanShowViewModel(viewModel, context, parentPresenter))
            {
                return(null);
            }

            INavigationProvider provider;

            if (!viewModel.GetIocContainer(true).TryGet(out provider))
            {
                return(null);
            }

            var operation = new AsyncOperation <object>();

            _operationCallbackManager.Register(OperationType.PageNavigation, viewModel, operation.ToOperationCallback(), context);
            operation.Context.AddOrUpdate(NavigationConstants.NavigationCompletedTask, provider.NavigateAsync(context));
            return(operation);
        }