Partager via


WebBrowser.Source Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the URI source of the HTML content to display in the WebBrowser control.

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

Syntax

'Declaration
Public Property Source As Uri
public Uri Source { get; set; }
<WebBrowser Source="uriString"/>

Property Value

Type: System.Uri
The URI source of the HTML content to display in the WebBrowser control.

Remarks

The specified URI can be fully qualified or be a relative URI. When you set the Source property in XAML and use a relative URI you should use the following convention:

  • Source="/Page1.html" is an application level resource that gets resolved to the base URI of the application (XAP file). This means the relative URI must resolve to the same site of origin as the application.

You cannot specify a URL to an embedded or local resource.

Examples

The following example shows a WebBrowser with its Source property set to an HTML page.

<TextBlock Text="WebBrowser Control" />
<WebBrowser Source="https://localhost/HTMLPage1.html" Height="160" Width="160" x:Name="WB1"/>
<Button Width="200" x:Name="Button1" Content="Click for HTML content" Click="Button1_Click"   />

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.