Mem*_*hiZ 4 browser wpf scroll
在 Windows 窗体应用程序中,我使用以下代码在 Web 浏览器中滚动页面:
HtmlDocument doc = webBrowser.Document;
mshtml.IHTMLDocument2 htmldoc = (mshtml.IHTMLDocument2)doc.DomDocument;
htmldoc.parentWindow.scrollBy(265, 20);
Run Code Online (Sandbox Code Playgroud)
有谁知道如何在 WPF 应用程序中做同样的事情(不使用 WindowsFormsHost)?
如果您使用System.Windows.Controls.WebBrowser类,请查看Document属性。您应该能够将其转换为 mshtml.HTMLDocument 或 mshtml.IHTMLDocument2 和代码
mshtml.HTMLDocument htmlDoc = webBrowser.Document as mshtml.HTMLDocument;
if (htmlDoc != null) htmlDoc.parentWindow.scrollBy(265, 20);
Run Code Online (Sandbox Code Playgroud)
应该适合你。
希望这有帮助,问候