Scroll to a postion in a Web Browser using Wpf

空扰寡人 提交于 2019-12-11 09:49:40

问题


I cannot seem to programmatcally scroll in WPF in a normal Windows Form I would use the code below but that property does not exist in WPF.

HtmlDocument doc = this.webBrowser1.Document;
doc.Body.ScrollTop = 800;
return; 

Is there an alternative to doing this?


回答1:


Not exaclty sure what to look for in that code, but I basically have a WebControl that shows a Webpage that has several articles. I would like to jump to an article by it's title. I know I can get the index of the article name, but jumping to it is the issue.




回答2:


How about this?

if (wb.Document is mshtml.HTMLDocument htmlDoc)
{
    htmlDoc.parentWindow.scrollTo(0, 0);
}


来源:https://stackoverflow.com/questions/238792/scroll-to-a-postion-in-a-web-browser-using-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!