This documentation is archived and is not being maintained.

WebBrowser Class

Updated: July 2008

Hosts and navigates between HTML documents. Enables interoperability between WPF managed code and HTML script.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public ref class WebBrowser sealed : public ActiveXHost, 
<WebBrowser .../>

The WebBrowser control provides the following capabilities:

Navigation: Source, Navigate, NavigateToStream, NavigateToString, Refresh, and Refresh.

Navigation Lifetime: Navigating, Navigated, and LoadCompleted.

Navigation Journaling: CanGoBack, GoBack, CanGoForward, and GoForward.

WPF/HTML Interoperability: InvokeScript and ObjectForScripting, and Document.

WebBrowser is bound by the security constraints of the WPF application that is hosting the WebBrowser:

  • When WebBrowser is hosted by a full-trust WPF application (a stand-alone application, for example), WebBrowser can host HTML documents from any location.

  • When WebBrowser is hosted by a partial-trust WPF application (an XBAP, for example), WebBrowser can only host documents that are Site Of Origin application data files. For more information, see Windows Presentation Foundation Application Resource, Content, and Data Files.

The following example shows how to configure WebBrowser to navigate to an HTML document by using markup only.

<!-- Web Browser Control that hosts a web page. -->
<WebBrowser x:Name="webBrowser" Source="" 
  Width="600" Height="600"  />

The following example shows how to configure WebBrowser to navigate to a document by using markup and code-behind.

        <StackPanel Orientation="Horizontal">
            <TextBox x:Name="addressTextBox" Width="200" />
            <Button Click="goNavigateButton_Click">Go</Button>
        <WebBrowser x:Name="myWebBrowser" />
        private void goNavigateButton_Click(object sender, RoutedEventArgs e)
            // Get URI to navigate to
            Uri uri = new Uri(this.addressTextBox.Text, UriKind.RelativeOrAbsolute);

            // Only absolute URIs can be navigated to
            if (!uri.IsAbsoluteUri)
                MessageBox.Show("The Address URI must be absolute eg ''");

            // Navigate to the desired URL by calling the .Navigate method


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1, 3.0 SP2




July 2008

Added topic for new class.

SP1 feature change.