public virtual void OnNavigated(NavigationEventArgsBase e)
 {
     EventHandler<INavigationService, NavigationEventArgsBase> handler = Navigated;
     if (handler != null) handler(this, e);
 }
        private void UpdateNavigationContext(IOperationCallback callback, IViewModel navigationViewModel, NavigationEventArgsBase args, ref INavigationContext context)
        {
            var vmType = context.GetData(ViewModelTypeConstant);
            if (vmType == null)
                return;

            var viewModel = GetViewModelForView(args, navigationViewModel, context, vmType);
            if (!ReferenceEquals(context.ViewModelTo, viewModel))
                context = new NavigationContext(NavigationType.Page, context.NavigationMode, context.ViewModelFrom, viewModel, context.NavigationProvider);
            if (viewModel != null && callback != null)
                RegisterOperationCallback(viewModel, callback, context);
        }
        protected virtual INavigationContext CreateContextNavigateTo(IViewModel viewModelFrom, NavigationEventArgsBase args)
        {
            string idOperation;
            var vmType = GetViewModelTypeFromParameter(NavigationService.GetParameterFromArgs(args), out idOperation);
            var viewModelTo = idOperation == _currentOperationId ? _navigationTargetVm : null;
            if (vmType == null)
            {
                if (args.Content != null)
                {
                    var items = _mappingProvider.FindMappingsForView(args.Content.GetType(), false);
                    if (items.Count == 1)
                    {
                        var type = items[0].ViewModelType;
#if WINDOWSCOMMON || XAMARIN_FORMS
                        if (!type.GetTypeInfo().IsGenericTypeDefinition)
#else
                        if (!type.IsGenericTypeDefinition)
#endif

                            vmType = type;
                    }
                }
                if (vmType == null)
                    return new NavigationContext(NavigationType.Page, args.Mode, viewModelFrom, viewModelTo, this)
                    {
                        {NavigationArgsConstant, args},
                        {OperationIdConstant, idOperation}
                    };
            }
            return new NavigationContext(NavigationType.Page, args.Mode, viewModelFrom, viewModelTo, this)
            {
                {NavigationArgsConstant, args},
                {ViewModelTypeConstant, vmType},
                {OperationIdConstant, idOperation}
            };
        }
 /// <summary>
 ///     Subscriber to the Navigated event.
 /// </summary>
 protected virtual void NavigationServiceOnNavigated(object sender, NavigationEventArgsBase e)
 {
     string idOperation = null;
     try
     {
         var context = CreateContextNavigateTo(CurrentViewModel, e);
         idOperation = context.GetData(OperationIdConstant);
         IOperationCallback callback = null;
         if (idOperation == _currentOperationId)
         {
             callback = _currentCallback;
             _currentCallback = null;
             _navigationTargetVm = null;
             _lastContext = null;
         }
         UpdateNavigationContext(callback, context.ViewModelTo, e, ref context);
         OnNavigated(context);
     }
     finally
     {
         if (idOperation == _currentOperationId)
         {
             _currentOperationId = null;
             var tcs = _navigatedTcs;
             if (tcs != null)
             {
                 _navigatedTcs = null;
                 tcs.TrySetResult(null);
             }
         }
     }
 }
 private void RaiseNavigated(NavigationEventArgsBase args)
 {
     var handler = Navigated;
     if (handler != null)
         handler(this, args);
 }
 private void RaiseNavigated(NavigationEventArgsBase args)
 {
     Navigated?.Invoke(this, args);
 }