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 363<br />

Embedded XAML reference: XAML can also be embedded within a tag within<br />

your HTML. Should you use this approach, you will need to name the tag, <strong>and</strong> then<br />

set the Source property of the <strong>Silverlight</strong> control to this value, prefixed with #.<br />

Using Embedded XAML<br />

Here’s an example of a tag that contains XAML:<br />

<br />

<br />

<br />

Hello World<br />

<br />

<br />

As you can see, this script block has been called xamlContent. Thus, when initializing<br />

the <strong>Silverlight</strong> control, you would set its source to #xamlContent, like this:<br />

function create<strong>Silverlight</strong>()<br />

{<br />

<strong>Silverlight</strong>.createObjectEx({<br />

source: "#xamlContent",<br />

parentElement: document.getElementById("<strong>Silverlight</strong>ControlHost"),<br />

id: "<strong>Silverlight</strong>Control",<br />

properties: {<br />

width: "100%",<br />

height: "100%",<br />

version: "1.0"<br />

},<br />

events: {<br />

onLoad: h<strong>and</strong>leLoad<br />

}<br />

});<br />

}<br />

The parentElement Property<br />

This is the name of the element that contains the <strong>Silverlight</strong> component within the<br />

HTML. In order for your <strong>Silverlight</strong> application to work correctly, this property must be<br />

set, <strong>and</strong> it must be set to the correct value.

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

Saved successfully!

Ooh no, something went wrong!