等效于WebView2中CEF的OnLoadingStateChange

问题描述

在承载WebView2控件的WPF应用程序中,我想 跟踪浏览器的加载状态,就像 在CEF中执行“ OnloadingStateChange”。

如何在WebView2中实现相同的目的?

解决方法

在WebView2的顶级文档导航到新URI之前分派CoreWebView2.NavigationStarting event,在导航失败或加载文档之后分派CoreWebView2.NavigationCompleted。这是WebView2 navigation events上的信息。

从WPF WebView2控件中,您可以使用CoreWebView2属性查找所有导航事件。 after the WebView2 is initialized提供了CoreWebView2属性。

Diagram of WebView2 navigation event state diagram.

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...