Silverlight Primer 9, Listing 1

Using the Silverlight Downloader object to download files from within a Silverlight application.

 function CreateSilverlight()
{
  Silverlight.createObjectEx(
    {
      source: "Default.xaml",
      parentElement: document.getElementById("divSilverlight"),
      id: "slControl",
      properties: { 
        width: "400", 
        height: "400", 
        version: "1.0" 
      },
      events: { 
   onLoad: onLoad, 
   onError: null 
}
    }
  );
}

function onLoad(control, context, rootElement)
{
  var downloader = control.CreateObject("downloader");
  //Attach to Downloader object events
  downloader.AddEventListener("DownloadProgressChanged", 
    onProgressChanged);
  downloader.AddEventListener("Completed", onCompleted);
  // Avoid caching by adding date on end of querystring
  downloader.Open("GET", "XAMLFiles.zip?" + new Date()); 
  downloader.Send();
}
comments powered by Disqus
Most   Popular
Upcoming Events

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.