Creates XAML content dynamically using downloader content.
| XAML | Cannot use methods in XAML. |
| Scripting | retval = silverlightObject.content.CreateFromXamlDownloader(downloader, part)
|
Parameters
| downloader | Downloader The object containing the downloaded
content. |
| part | string The name of the specific part of the downloaded
content package. When the downloaded content package is a Zip file, part refers to the contents of a filename within downloader. If the downloaded content does not represent packaged content, set part to an empty string. |
Return Value
object
An object reference if the XAML content was successfully created;
otherwise, returns null.
Examples
The following JavaScript example shows how to add XAML content to an existing Canvas object using the CreateFromXamlDownloader method. Because the downloaded content does not represent packaged content, the part parameter for CreateFromXamlDownloader is set to an empty string:
| JavaScript |
// Event handler for the Completed event.
function onCompleted(sender, eventArgs)
{
// Retrieve a reference to the plug-in.
var slPlugin = sender.getHost();
// Retrieve the XAML fragment and create an object reference.
// In this case, since the downloaded content represents a single file, OK_button.xaml,
// the part parameter is set to an empty string.
var xamlFragment = slPlugin.content.createFromXamlDownloader(sender, "");
// Add the XAML object as a child of the root Canvas object.
var root = sender.findName("rootCanvas");
root.children.add(xamlFragment);
}
|
You can also use the CreateFromXamlDownloader method to retrieve a specific part within the downloaded content package. When the downloaded content package is a Zip file, the CreateFromXamlDownloader method retrieves the contents of a filename within the Zip file.
The following JavaScript example shows how to use the CreateFromXamlDownloader method, using the part parameter to reference as specified part within the downloaded content:
| JavaScript |
// Event handler for the Completed event.
function onCompleted(sender, eventArgs)
{
// Retrieve a reference to the plug-in.
var slPlugin = sender.getHost();
// Retrieve the specified XAML file from the packaged downloader content,
// and create an object reference.
var xamlFragment = slPlugin.content.createFromXamlDownloader(sender, "OK_button.xaml");
// Add the XAML object as a child of the root Canvas object.
var root = sender.findName("rootCanvas");
root.children.add(xamlFragment);
}
|
Applies To
Silverlight Plug-in
See Also
Using a Downloader Object
Silverlight XAML Syntax