Represents the set of download functionality for a Silverlight plug-in. The downloader can asynchronously download content that can be obtained through an HTTP GET request.
| XAML | Cannot be used in XAML. |
| Scripting | To create a Downloader object using scripting, see CreateObject. |
Properties
DownloadProgress,
Name,
ResponseText,
Status,
StatusText,
Uri
Methods
Abort,
Equals,
FindName,
GetHost,
GetResponseText,
GetValue,
Open,
Send,
SetValue
Events
Completed,
DownloadFailed,
DownloadProgressChanged
Examples
The following JavaScript example shows how to create, initialize, and execute a download request. This example hooks event handlers for two events ( Completed, DownloadProgressChanged), but these handlers are not shown in this example. Also, there is a third event DownloadFailed that you might want to write handlers for in some cases. See the complete example in the topic Using a Downloader Object.
| JavaScript |
// Event handler for initializing and executing a download request.
function onMouseLeftButtonUp(sender, eventArgs)
{
// Retrieve a reference to the plug-in.
var slPlugin = sender.getHost();
// Create a Downloader object.
var downloader = slPlugin.createObject("downloader");
// Add DownloadProgressChanged and Completed events.
downloader.addEventListener("downloadProgressChanged", onDownloadProgressChanged);
downloader.addEventListener("completed", onCompleted);
// Initialize the Downloader request.
// NOTE: downloader APIs disallow file:\\ scheme
// you must run this sample over localhost: or off a server or the following call will fail
downloader.open("GET", "promo.png");
// Execute the Downloader request.
downloader.send();
}
|
See Also
Using a Downloader Object
CreateFromXamlDownloader
CreateObject
SetSource (Image)
SetSource (MediaElement)