/// <summary> /// Gets the view to which the navigation request represented by <paramref name="navigationContext"/> applies. /// </summary> /// <param name="region">The region.</param> /// <param name="navigationContext">The context representing the navigation request.</param> /// <returns> /// The view to be the target of the navigation request. /// </returns> /// <remarks> /// If none of the views in the region can be the target of the navigation request, a new view /// is created and added to the region. /// </remarks> /// <exception cref="ArgumentException">when a new view cannot be created for the navigation request.</exception> public object LoadContent(IRegion region, INavigationContext navigationContext) { if (region == null) { throw new ArgumentNullException(nameof(region)); } if (navigationContext == null) { throw new ArgumentNullException(nameof(navigationContext)); } string candidateTargetContract = GetContractFromNavigationContext(navigationContext); var candidates = GetCandidatesFromRegion(region, candidateTargetContract); var acceptingCandidates = candidates.Where( v => MvvmHelpers.IsNavigationTarget(v, navigationContext)); var view = acceptingCandidates.FirstOrDefault(); if (view != null) { return(view); } var activeRegion = _container.Resolve <IActiveRegionHelper>(); activeRegion.ActiveRegion = region; view = CreateNewRegionItem(candidateTargetContract) as VisualElement; activeRegion.ActiveRegion = null; region.Add(view); return(view); }