08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 15 ■ ENHANCING THE WEB EXPERIENCE WITH SILVERLIGHT 373<br />

If you want to monitor the download progress <strong>and</strong> completion status, you can wire<br />

up the appropriate event h<strong>and</strong>lers. Here’s an example:<br />

downloader.addEventListener("downloadProgressChanged", "h<strong>and</strong>leDLProgress");<br />

downloader.addEventListener("completed", "h<strong>and</strong>leDLComplete");<br />

Now you can implement these h<strong>and</strong>lers:<br />

function h<strong>and</strong>leDLProgress(sender, args)<br />

{<br />

var ctrl = sender.getHost();<br />

var t1 = ctrl.content.findName("txt1");<br />

var v = sender.downloadProgress * 100;<br />

t1.Text = v + "%";<br />

}<br />

function h<strong>and</strong>leDLComplete(sender, args)<br />

{<br />

alert("Download complete");<br />

}<br />

Summary<br />

In this chapter, you took a look at <strong>Silverlight</strong> <strong>and</strong> how <strong>Silverlight</strong> applications are constructed.<br />

You worked your way through the anatomy of a typical <strong>Silverlight</strong> application<br />

before embarking on a tour of the <strong>Silverlight</strong> control <strong>and</strong> its various properties, methods,<br />

<strong>and</strong> events.<br />

In the next chapter, you will look at XAML, <strong>and</strong> take a tour of the XAML controls that<br />

are supported by <strong>Silverlight</strong>. You’ll also look into their JavaScript API, rounding out the<br />

programming aspects of working in <strong>Silverlight</strong>. This will hopefully serve as a launch<br />

board for you to go out <strong>and</strong> get more involved with the technology!

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!