Dan Vogel
Dan Vogel

Reputation: 3938

Scrollable Height of System.Windows.Controls.WebBrowser

I am using the System.Windows.Controls.WebBrowser control, and I need to get the height of the rendered html document. (Not the height of the control, the height of the content)

The only height value I've found is WebBrowser.Document.body.offsetheight. However, this is the same value as the control's height.

I know the height of the page must be stored someplace since the scroll bar knows the value.

Everything I find in my searching has been about the Windows.Forms.WebBrowser.

Upvotes: 1

Views: 1793

Answers (1)

Dan Vogel
Dan Vogel

Reputation: 3938

Add COM reference "Microsoft HTML Object Library" to the project, and use this:

mshtml.HTMLDocument doc = (mshtml.HTMLDocument)this.Browser1.Document;
mshtml.IHTMLElement2 elem = (mshtml.IHTMLElement2)doc.activeElement;
int height = elem.scrollHeight;

Upvotes: 1

Related Questions