SilverlightHost.Source Property


Gets the URI of the package or XAML file that specifies the XAML content to render.

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

Public ReadOnly Property Source As Uri

Property Value

Type: System.Uri
The URI of the package, XAML file, or XAML scripting tag that contains the content to load into the Silverlight plug-in.

You set the Silverlight plug-in source property when you embed the Silverlight plug-in in a Web page. In managed code, this property is read-only. However, you can modify the source property through the HTML DOM. Doing this causes the current application instance to unload.

Most applications for Silverlight specify the source to be the application package (XAP) instead of a XAML file. The package would contain application manifest and other support so that the initial XAML page to load was specified. For more information, see Application and Programming Models. Specifying a XAML file is still an option, but will not provide the support that is enabled by the application model in Silverlight. For more information, see Source (Silverlight Plug-in Object).

The following code example demonstrates how to use this property.

' The Host object, which represents the host Silverlight plug-in. 
Dim host As System.Windows.Interop.SilverlightHost = _

' The following code demonstrates how to use the Host object 
' to access other APIs in the System.Windows.Interop namespace. 

' The IsVersionSupported method. This method is useful when 
' you want to implement an upgrade experience in managed code. 
Dim isSupported As Boolean = host.IsVersionSupported("2.0.30908.0")

' Read-only properties of the Host object. 
Dim pluginBackground As System.Windows.Media.Color = host.Background
Dim loaded As Boolean = host.IsLoaded
Dim source As Uri = host.Source

' The Settings object, which represents Web browser settings. 
Dim settings As System.Windows.Interop.Settings = host.Settings

' Read/write properties of the Settings object. 
settings.EnableFrameRateCounter = True
settings.EnableRedrawRegions = True
settings.MaxFrameRate = 60

' Read-only properties of the Settings object. 
Dim windowless As Boolean = settings.Windowless
Dim htmlAccessEnabled As Boolean = settings.EnableHTMLAccess

' The Content object, which represents the plug-in display area. 
Dim content As System.Windows.Interop.Content = host.Content

' The read/write IsFullScreen property of the Content object. 
' See also the Content.FullScreenChanged event. 
Dim isFullScreen As Boolean = content.IsFullScreen

' Read-only properties of the Content object. These properties do 
' not contain meaningful values until after the Content.Resized 
' event occurs for the first time. 
Dim actualWidth As Double = content.ActualWidth
Dim actualHeight As Double = content.ActualHeight


Supported in: 5, 4, 3

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

Community Additions