0

I need to calculate the position and size of pre-determined markers in a large HTML document, exactly as they would appear in a XAML WebView (this information is used later when the user is viewing the document).

To this end, I've instantiated a WebView and am waiting for ScriptNotify events to get data back from javascript on the page.

var webview = new WebView();
webview.ContentLoading += webview_ContentLoading; // just writes a line to debug
webview.ScriptNotify += webview_ScriptNotify; // stores data passed up from js
var resolver = new WebViewStreamResolver(); // simple implementation serving up local files
var uri = webview.BuildLocalStreamUri("foo", "/page-with-scripts.html");
webview.NavigateToLocalStreamUri(uri, resolver);

With this code, the ContentLoading and ScriptNotify events are never fired. Using the DOM inspector (in Script debug mode) shows that the DOM is empty. Inspecting the webview variable (in Managed debug mode) shows that the webview's location is an empty string.

The same code in a XAML code-behind (without the first line) for a XAML document that contains a webview works as expected.

What am I doing wrong?

  • Have you tried adding it the tree but with a one by one size? – Jerry Nixon Feb 17 '15 at 04:05
  • I'm already working around this behavior with a webview that's pushed off the screen. What I'm hoping for now is an explanation for this behavior. –  Feb 17 '15 at 07:14

1 Answers1

0

I believe I have already written this for you, or something close :)

How do I print WebView content in a Windows Store App?

Best of luck!

Community
  • 1
  • 1
Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233
  • I don't see how the printing of a webview (that is in the visual tree) is applicable to my problem, that the webview is unresponsive when it isn't attached to a parent element that is in the visual tree. –  Feb 11 '15 at 01:59