internal NavigationEventArgsAdapter( NavigationFailedEventArgs source ) { Contract.Requires( source != null ); this.source = source; IsSuccess = false; }
// Code to execute if a navigation fails private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { if (Debugger.IsAttached) { // A navigation has failed; break into the debugger Debugger.Break(); } }
HResult IExplorerBrowserEvents.OnNavigationFailed(IntPtr pidlFolder) { if (NavigationFailed != null) { NavigationFailedEventArgs args = new NavigationFailedEventArgs(); args.FailedLocation = ShellObjectFactory.Create(pidlFolder); NavigationFailed(this, args); } return HResult.Ok; }
/// <summary> /// Clears the Explorer Browser of existing content, fills it with /// content from the specified container, and adds a new point to the Travel Log. /// </summary> /// <param name="shellObject">The shell container to navigate to.</param> /// <exception cref="System.Runtime.InteropServices.COMException">Will throw if navigation fails for any other reason.</exception> public void Navigate(ShellObject shellObject) { if (shellObject == null) { throw new ArgumentNullException("shellObject"); } if (explorerBrowserControl == null) { antecreationNavigationTarget = shellObject; } else { HResult hr = explorerBrowserControl.BrowseToObject(shellObject.NativeShellItem, 0); if (hr != HResult.Ok) { if ((hr == HResult.ResourceInUse || hr == HResult.Canceled) && NavigationFailed != null) { NavigationFailedEventArgs args = new NavigationFailedEventArgs(); args.FailedLocation = shellObject; NavigationFailed(this, args); } else { throw new CommonControlException(LocalizedMessages.ExplorerBrowserBrowseToObjectFailed, hr); } } } }
/// <summary> /// Clears the Explorer Browser of existing content, fills it with /// content from the specified container, and adds a new point to the Travel Log. /// </summary> /// <param name="shellObject">The shell container to navigate to.</param> /// <exception cref="System.Runtime.InteropServices.COMException">Will throw if navigation fails for any other reason.</exception> public void Navigate(ShellObject shellObject) { if (explorerBrowserControl == null) { antecreationNavigationTarget = shellObject; } else { HRESULT hr = explorerBrowserControl.BrowseToObject(shellObject.NativeShellItem, 0); if (hr != HRESULT.S_OK) { if (hr == HRESULT.RESOURCE_IN_USE) { if (NavigationFailed != null) { NavigationFailedEventArgs args = new NavigationFailedEventArgs(); args.FailedLocation = shellObject; NavigationFailed(this, args); } } else throw new COMException("BrowseToObject failed", (int)hr); } } }
void OnNavigationFailed(object sender, NavigationFailedEventArgs e) { throw new Exception("Failed to load Page " + e.SourcePageType.FullName); }
private void OnNavigationFailed(NavigationFailedEventArgs e) { if (NavigationFailed != null){ NavigationFailed(this, e); } }
private void Navigate(Uri oldValue, Uri newValue, NavigationType navigationType) { Debug.WriteLine("Navigating from '{0}' to '{1}'", oldValue, newValue); // set IsLoadingContent state SetValue(IsLoadingContentPropertyKey, true); // cancel previous load content task (if any) // note: no need for thread synchronization, this code always executes on the UI thread if (this.tokenSource != null) { this.tokenSource.Cancel(); this.tokenSource = null; } // push previous source onto the history stack (only for new navigation types) if (oldValue != null && navigationType == NavigationType.New) { this.history.Push(oldValue); } object newContent = null; if (newValue != null) { // content is cached on uri without fragment var newValueNoFragment = NavigationHelper.RemoveFragment(newValue); if (navigationType == NavigationType.Refresh || !this.contentCache.TryGetValue(newValueNoFragment, out newContent)) { var localTokenSource = new CancellationTokenSource(); this.tokenSource = localTokenSource; // load the content (asynchronous!) var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); var task = this.ContentLoader.LoadContentAsync(newValue, this.tokenSource.Token); task.ContinueWith(t => { try { if (t.IsCanceled || localTokenSource.IsCancellationRequested) { Debug.WriteLine("Cancelled navigation to '{0}'", newValue); } else if (t.IsFaulted) { // raise failed event var failedArgs = new NavigationFailedEventArgs { Frame = this, Source = newValue, Error = t.Exception.InnerException, Handled = false }; OnNavigationFailed(failedArgs); // if not handled, show error as content newContent = failedArgs.Handled ? null : failedArgs.Error; SetContent(newValue, navigationType, newContent, true); } else { newContent = t.Result; if (ShouldKeepContentAlive(newContent)) { // keep the new content in memory this.contentCache[newValueNoFragment] = newContent; } SetContent(newValue, navigationType, newContent, false); } } finally { // clear global tokenSource to avoid a Cancel on a disposed object if (this.tokenSource == localTokenSource) { this.tokenSource = null; } // and dispose of the local tokensource localTokenSource.Dispose(); } }, scheduler); return; } } // newValue is null or newContent was found in the cache SetContent(newValue, navigationType, newContent, false); }
private void Frame_NavigationFailed(object sender, NavigationFailedEventArgs e) { NavigationFailed?.Invoke(sender, e); }
/// <summary> /// Invoked when Navigation to a certain page fails /// </summary> /// <param name="sender">The Frame which failed navigation</param> /// <param name="e">Details about the navigation failure</param> void OnNavigationFailed(object sender, NavigationFailedEventArgs e) { throw new Exception("Failed to load Page " + e.SourcePageType.FullName); }
private void Frame_NavigationFailed(object sender, NavigationFailedEventArgs e) { throw e.Exception; }
/// <summary> /// 导航到特定页失败时调用 /// </summary> ///<param name="sender">导航失败的框架</param> ///<param name="e">有关导航失败的详细信息</param> private void OnNavigationFailed(object sender, NavigationFailedEventArgs e) { Conf.Log($"unable to load page: {e.SourcePageType.FullName}.", LogLevel.Warning); }
// Код для выполнения в случае ошибки навигации private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { if (System.Diagnostics.Debugger.IsAttached) { // Ошибка навигации; перейти в отладчик System.Diagnostics.Debugger.Break(); } }
/// <summary> /// Invoked when Navigation to a certain page fails /// </summary> /// <param name="sender">The Frame which failed navigation</param> /// <param name="e">Details about the navigation failure</param> private static void OnNavigationFailed(object sender, NavigationFailedEventArgs e) => throw new Exception($"Failed to load {e.SourcePageType.FullName}: {e.Exception}");
/// <summary> /// Invoked when Navigation to a certain page fails /// </summary> /// <param name="sender">The Frame which failed navigation</param> /// <param name="e">Details about the navigation failure</param> void OnNavigationFailed(object sender, NavigationFailedEventArgs e) { throw new Exception($"Failed to load Page {e.SourcePageType}: {e.Exception}"); }