Поделиться через


Source (Silverlight Plug-in Object)

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

Gets or sets the Uniform Resource Identifier (URI) of either the initial XAML file (JavaScript API) or XAP package (managed API) that specifies or contains the content to display.

Syntax

object Element

<object ...>
  <param name="source" value="sourceUri"/>
  ...
</object>

Silverlight.js

Silverlight.CreateObject('sourceUri');
-or-
Silverlight.CreateObjectEx({source:'sourceUri'})

JavaScript

value = silverlightObject.Source;
silverlightObject.Source = sourceUri;

COM

IXcpControl::Source

Managed Code

See SilverlightHost.Source. This property is read-only for managed code.

Property Value

The URI of the content or package to load into the Silverlight plug-in. The default is null.

Remarks

Changing the Source value at run time is permitted, under either the JavaScript API or the HTML DOM. This can affect performance. For the JavaScript API, this operation is equivalent to removing and adding the object element for the Silverlight plug-in using the DOM. If you reset Source, all state from the previous instance of the Silverlight plug-in is lost. Calling the CreateFromXaml method and rebuilding the object tree below the original root can provide better performance than resetting the Source property.

Changing the Source value at run time is not enabled through any managed API. You must use the DOM or manipulate the hosting HTML page in order to change the Source value for a managed-API application. In managed APIs, typically you would instead use a navigation framework or metaphor that does not require reloading the source XAP; see Navigation Overview.

The string value of the Source property is interpreted as a URI instead of as an Internationalized Resource Identifier (IRI). Characters that are used to identify a Source value that are outside the US-ASCII character set must be encoded.

A Source URI can represent a relative path. The relative path is based on the location of the HTML page that contains the object element. If you use a relative path, always use the slash character (/) for traversal. Silverlight does not support the backslash character (\) for relative paths.

The # (number sign) prefix in the string specifies a Source value that references inline XAML. However, inline XAML is supported only for the JavaScript API, and has substantial limitations. See Using Inline XAML.