Instead of setting the initial Silverlight content with a discrete file or package referenced by a Uniform Resource Identifier (URI), you should specify an inline HTML content area that contains XAML.
Important NOTE:
Inline XAML is the concept of a JavaScript API that is only available for Silverlight. Inline XAML is not compatible with Silverlight's managed APIs.
Using inline XAML
Because of its relationship to the browser DOM, inline XAML constitutes a thoughtful choice to use the JavaScript API. If you do not have a discrete XAML file that is understood by the managed project file (the file is specified in its root directory), the inline XAML solution cannot understand how to connect code-behind and XAML, and there is no specific directive to compile and connect managed code. x:class
To use inline XAML, you must include the XAML in a special <SCRIPT> block and specify "Text/xaml" as the Type property. The XML document type declaration <?xml version= "1.0"?> is located before the XAML content. The XAML content must be uniquely identified so that the Source initialization parameter of the Silverlight plug-in can reference it. The source parameter identifies the XAML content with the prefix "#" in the <SCRIPT> element, followed by the ID value. XAML content can also define events that reference event handlers on an HTML page.
The following HTML example shows how to create an inline XAML content. In this case, the HTML page contains both JavaScript and XAML content. Note the OBJECT element construction that specifies the source parameter.
Description
The <SCRIPT> element that contains inline XAML content must precede the HTML element that contains the Silverlight plug-in, which references the inline XAML for its source initialization.
<title>display date</title>
<!--Define Loaded event handler for TextBlock. -->
<script type= "Text/javascript" >
function setdate (sender, EventArgs)
{
Sender.text = Date ();
}
</script>
<body bgcolor= "Teal" >
<!--Define XAML content. -->
<script type= "Text/xaml" id= "xamlcontent" ><?xml version= "1.0"?>
<canvas
Xmlns= "http://schemas.microsoft.com/client/2007"
background= "Wheat" >
<textblock
Canvas.left= "20"
Fontsize= "24"
loaded= "Setdate"/>
</Canvas>
</script>
<div id= "Silverlightcontrolhost" >
<object type= "Application/x-silverlight" width= "100%" height= "100%" id= "SLC" >
<param name= "source" value= "#xamlContent"/>
<param name= "onload" value= "onloaded"/>
<param name= "iswindowless" value= "true"/>
</object>
<iframe style= ' visibility:hidden;height:0;width:0;border:0px ' ></iframe>;
</div>
</body>
When this page is displayed, the Silverlight plug-in is loaded and the Loaded event is raised for the TextBlock object, which causes the TextBlock to display the current date and time.