private void ContentLoader_BeginLoad_Callback(IAsyncResult result) { DependencyObject content = null; Uri uriBeingLoaded = null; try { NavigationOperation asyncNavigationOperationCompleted = result.AsyncState as NavigationOperation; NavigationOperation navOp = this._currentNavigation; if (navOp == null || navOp.Uri != asyncNavigationOperationCompleted.Uri) { // We already fired NavigationStopped in NavigateCore(), so just return without doing anything return; } uriBeingLoaded = navOp.UriBeforeMapping; content = this._contentLoader.EndLoad(result) as DependencyObject; // If the content is anything but a UserControl, we should throw. // We support UserControls as they are a typical thing created in designers such as Blend, // but for a full experience one would use Page to get to things like NavigationContext, // NavigationService, Title, etc. if (!(content is UserControl)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, Resource.NavigationService_ContentIsNotAUserControl, content == null ? "null" : content.GetType().ToString(), "System.Windows.Controls.UserControl")); } // Content loader was successful, so complete navigation // Create a new navigation context JournalEntry.SetNavigationContext(content, new NavigationContext(UriParsingHelper.InternalUriParseQueryStringToDictionary(asyncNavigationOperationCompleted.Uri, true /* decodeResults */))); content.SetValue(NavigationServiceProperty, this); // Complete navigation operation this.CompleteNavigation(content); } catch (Exception ex) { if (this.RaiseNavigationFailed(uriBeingLoaded, ex)) { throw; } } }