首先,我是一个C#的新手,并在学习Cefsharp + javascript的过程中逐步实践,因此请尝试评论您认为必要的任何解决方案,这将避免我提出愚蠢的问题。
我正在尝试使用Cefsharp等待页面完成加载后执行我的代码,我尝试了其他stackoverflow问题/ github上找到的几个解决方案,但没有用。
我认为解决方案是"NavStateChanged",但我收到一个C#错误: "ChromiumWebBrowser不包含“NavStateChanged”的定义"
能否指点我正确的方向或给我一些提示?我不是让您为我编写整个代码,但我真的迷失了方向,同时学习C#、Cefsharp和JavaScript是一件艰巨的任务。
这是我在寻找在线解决方案时找到的代码,它也与许多github引用匹配,但似乎无法工作:/
EventHandler<NavStateChangedEventArgs> handler = null;
handler = (sender, args) = > {
//TODO : show a loading gif until the page load completes
//Wait for while page to finish loading not just the first frame
if (!args.IsLoading)
{
chromeBrowser.NavStateChanged -= handler;
MessageBox.Show("The page has completed loading", "Load completed",
MessageBoxButtons.OK);
//TODO : once load complete show the actual page
}