Using Inline XAML with Silverlight, Listing 2
Silverlight provides support for embedding XAML "inline" within a page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Inline XAML</title>
<script type="text/javascript"
src="Scripts/Silverlight.js"></script>
</head>
<body>
<!-- Inline XAML -->
<script type="text/xaml" id="inlineXAML"><?xml version="1.0"?>
<Canvas xmlns="http://schemas.microsoft.com/client/2007"
Background="Navy" Height="200" Width="400">
<Rectangle Name="Rect" Canvas.Top="75"
Canvas.Left="100" Width="200" Height="100"
Fill="Gray" />
<TextBlock
Canvas.Left="20" Canvas.Top="75"
FontSize="30"
Foreground="Yellow"
Text="Hello from Inline XAML"></TextBlock>
</Canvas>
</script>
<div id="slHost">
<script type="text/javascript">
Silverlight.createObjectEx(
{
source: "#inlineXAML",
parentElement: document.getElementById("slHost"),
id: "slControl",
properties:
{
width: "400",
height: "200",
version: "1.0"
},
events: null
}
);
</script>
</div>
</body>
</html>