private void loadHtmlDocWithScriptButton_Click(object sender, RoutedEventArgs e) { // Load HTML document as a stream Uri uri = new Uri(@"pack://application:,,,/HTMLDocumentWithScript.html", UriKind.Absolute); Stream source = Application.GetResourceStream(uri).Stream; // Set object for scripting to allow HTML document to change this WPF window's title this.scriptableClass = new ScriptableClass(this); this.webBrowser.ObjectForScripting = this.scriptableClass; // Navigate to HTML document stream this.webBrowser.NavigateToStream(source); }