Set System.Windows.Controls.WebBrowser's conte

2019-05-25 08:39发布

问题:

I want to set up inline content of a WPF WebBrowser control:

<WebBrowser>
    <html>
        <body><b>Inline content.</b></body>
    </html>
</WebBrowser>

Or alternatively:

Dim wb As New WebBrowser
wb.Content = "<html><body><b>Programmatic content</b></body></html>"

回答1:

Call NavigateToString or NavigateToStream:

wb.NavigateToString("<html><body><b>Programmatic content</b></body></html>");

Yeah, they are badly named.