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?