Created
June 15, 2016 00:09
-
-
Save rohits79/ebe5684df53038a99ef6595c41cc4366 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public object LoadContent(IRegion region, NavigationContext navigationContext) | |
{ | |
if (region == null) | |
throw new ArgumentNullException(nameof(region)); | |
if (navigationContext == null) | |
throw new ArgumentNullException(nameof(navigationContext)); | |
string candidateTargetContract = this.GetContractFromNavigationContext(navigationContext); | |
var candidates = this.GetCandidatesFromRegion(region, candidateTargetContract); | |
var acceptingCandidates = | |
candidates.Where( | |
v => | |
{ | |
var navigationAware = v as INavigationAware; | |
if (navigationAware != null && !navigationAware.IsNavigationTarget(navigationContext)) | |
{ | |
return false; | |
} | |
var frameworkElement = v as FrameworkElement; | |
if (frameworkElement == null) | |
{ | |
return true; | |
} | |
navigationAware = frameworkElement.DataContext as INavigationAware; | |
return navigationAware == null || navigationAware.IsNavigationTarget(navigationContext); | |
}); | |
var view = acceptingCandidates.FirstOrDefault(); | |
if (view != null) | |
{ | |
return view; | |
} | |
view = this.CreateNewRegionItem(candidateTargetContract); | |
region.Add(view); | |
return view; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment